I have the following code:
struct A {
protected:
A() {}
A* a;
};
struct B : A {
protected:
B() { b.a = &b; }
A b;
};
It seems like a big limitation of the C++ language. How would you solve problem like this:
class Node
{
public:
void Save();
protected:
virtual void SaveState(int type) = 0;
};
class BinaryNode : public Node
{
protected:
Node *left;
Node *right;
virtual void SaveState(int type) override
{
left->SaveState(type);
right->SaveState(type);
}
};
In this example I do not want to make method SaveState
visible outside Node
hierarchy. Only method Save
should be public
.