I have two classes in the same .cpp file:
// forward
class B;
class A {
void doSomething(B * b) {
b->add();
}
};
class B {
void a
You must have the definition of class B before you use the class. How else would the compiler otherwise know that there exists such a function as B::add?
Either define class B before class A, or move the body of A::doSomething to after class B have been defined, like
class B;
class A
{
B* b;
void doSomething();
};
class B
{
A* a;
void add() {}
};
void A::doSomething()
{
b->add();
}