Then your code must not be arranged the way you think it is. The example you pasted works -- I cannot tell you what's wrong without more information. The following demo program compiles just fine (compile it to see for yourself):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <vector>
usingnamespace std;
class XXX
{
};
class YYY
{
vector<XXX*> v;
};
int main()
{
YYY y;
return 0;
}
Other possible solutions are to forward declare XXX before you declare YYY:
1 2 3 4 5 6
class XXX; // forward declaration
class YYY
{
vector<XXX*> v;
};
or forcibly #include "xxx.h" in "yyy.h" (be sure you protect your #include with typedef)
1 2 3 4 5 6 7 8 9
/// -- in xxx.h:
#ifndef __XXX_H_INCLUDED__
#define __XXX_H_INCLUDED__
class XXX
{
};
#endif
1 2 3 4 5 6 7 8 9 10 11 12
/// -- in yyy.h:
#ifndef __YYY_H_INCLUDED__
#define __YYY_H_INCLUDED__
#include "xxx.h"
class YYY
{
vector<XXX*> v;
};
#endif