This code doesn't do anything special. It's just a snippet to show the problem with forward declarations. Just a short question: why doesn't it work and how to force it to work?
class A;
class B {
A obj;
public:
int getB() const {
return 0;
}
void doSmth() {
int a = obj.getA();
}
};
class A {
B obj;
public:
int getA() const {
return 1;
}
void doSomething() {
int b = obj.getB();
}
};
This code gives me errors:
error C2079: 'B::obj' uses undefined class 'A'
error C2228: left of '.getA' must have class/struct/union