In a source file I have 2 class definitions
class Foo
{
public:
int * GetPtr(){
return Obj;
}
int * Obj;
}
class Bar
{
public:
...
std::vector<Foo> FooVector;
}
And in the same source file I have this function
void DoSomething()
{
Bar* barVar = CreateBar(); // Returns pointer to class object
Foo* fooVar = &barVar->FooVector[0];
if (fooVar->GetPtr()) // Error here
...
}
Trying to compile this, I get the error "Pointer to incomplete class type not allowed" but the class is defined a few lines above it.
我通过正确实现类来解决这个问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.