I have two classes in the same .cpp file:
// forward
class B;
class A?{
void doSomething(B * b) {
b->add();
}
};
class B {
void add() {
...
}
};
The forward does not work, I cannot compile.
I get this error:
error: member access into incomplete type 'B'
note: forward declaration of 'B'
I'm using clang compiler (clang-500.2.79).
I don't want to use multiple files (.cpp and .hh), I'd like to code just on one .cpp.
I cannot write the class B before the class A.
Do you have any idea of how to resolve my problem ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…