I’m trying to compile something like the following:
A.h
#include "B.h"
class A {
B * b;
void oneMethod();
void otherMethod();
};
A.cpp
#include "A.h"
void A::oneMethod() { b->otherMethod() }
void A::otherMethod() {}
B.h
#include "A.h"
class B {
A * a;
void oneMethod();
void otherMethod();
};
B.cpp
#include "B.h"
void B::oneMethod() { a->otherMethod() }
void B::otherMethod() {}
Until now I haven’t had problems using forward declarations, but I can use that now, because i can’t use atributtes or methods of only-forward-declarated classes.
How can I solve this?
As long as I’m understanding your question right, all you need to do is this:
A.h
A.cpp
B.h
B.cpp