I have a class like this:
class A {
protected:
class Node {
public:
int x;
Node* next;
};
Node* root;
.
.
.
};
And a lot of methods using this "root".
Now, say I want to inherit from A class, and make all the methods use a "better" node. Something like:
class B : public A{
class NewNode : public A::Node{
public:
int y;
};
NewNode* root;
.
.
.
};
Is there a way of doing something like this? And if not, what are the alternatives (beside rewriting A class)?
Thank you!
Since
NewNode
is derived fromNode
you can put something like this in theB
constructorMore realistically, you'll probably need something like this
You don't need a new variable in B, just use
A::root
.