Class losing data if returned from a function outside of the class

Get rid of the pointers for great good™. And while we’re at it, move as much as you can to the constructor.

AnotherClass classB::setupData()
{
    AnotherClass a(/* setup data */);
    return a;
}

Should get yourself rid of more than one problem at once.

Leave a Comment