The follwing code is compiled in VC++6. I don't understand why I am getting the compilation error "C2079: 'b' uses undefined class 'B'" for the following code?
//Class B Source
#include "B.h"
void B::SomeFunction()
{
}
//Class B Header
#include "A.h"
struct A;
class B
{
public:
A a;
void SomeFunction();
};
//struct A Header
#include "B.h"
class B;
struct A
{
B b;
};
If I changed class B header to the following, then there will be no error. But the header declaration won't be at the top!!!
//Class B Header with weird header declaration
struct A;
class B
{
public:
A a;
void SomeFunction();
};
#include "A.h"
Edit1: Changed Struct
to struct
Edit2: Changed void SomeFunction::SomeFunction()
to void B::SomeFunction()