...when declare and assign an instance of a user-defined struct in a function. And the struct (theStruct) is not declared in the same header file as the function (theFunction). Like this:
files:
"A.h": declares the struct in a class (theClass)
"A.cpp": implements the struct
"B.h": declares the function
"B.cpp": implements the function, error here
I think making the instance (inst) a reference might solve this. But the instance is assigned to a return value from a function (returnFunc). Like:
1 2 3 4 5 6 7
void theFunction() {
...
theClass::theStruct inst = returnFunc(...);
//returnFunc() returns an instance of theStruct
//the error is at 'inst'
...
}
are you just declaring the struct? ie struct theClass ? If so then you need to define the whole class in A.h (you can define its functions elsewhere).
This is because B.cpp doesn't know what the struct is (it knows it's a struct because you declared it, but not how big it is or what it's members are)