user3571201 user3571201 - 3 months ago 18
C++ Question

error C4430: missing type specifier - int assumed.

i have this error:

"error C4430: missing type specifier - int assumed. Note: C++ does not support default-int"

with this code example :

//A.h
#include "B.h"
class A{
B* b;
..
};

//B.h
#include "A.h"
class B{
A* a; // error error C4430: missing type specifier - int assumed.
};

Answer

In particular, to declare a pointer to some class, the actual definition of a class is not needed. So you don't need to include A.h in B.h, forward declaration is enough. Such as:

//B.h
class A; // change the include of A.h to forward declaration
class B { 
    A* a;
};
Comments