error: member access into incomplete type : forward declaration of

The Solution to error: member access into incomplete type : forward declaration of is


Move doSomething definition outside of its class declaration and after B and also make add accessible to A by public-ing it or friend-ing it.

class B;

class A
{
    void doSomething(B * b);
};

class B
{
public:
    void add() {}
};

void A::doSomething(B * b)
{
    b->add();
}

~ Answered on 2013-11-13 19:44:50


Most Viewed Questions: