Hello,
I have an abstract base class called Node, which has got two derived classes, IntNode and StringNode.
class Node{ //abstract class
private:
Node* lnk;
public:
Node();
virtual ~Node();
void link(Node* n);
Node* link() const;
virtual void print()const=0;
};
class IntNodeublic Node{
…//code here!
};
class StringNodeublic Node{
…//code here!
};
My question is, when I write:
Node* myNode=new IntNode;
I do not have access to the member functions in class IntNode (they are declared as public), I have only access to the functions in the base class, but when I write:
IntNode* myNode= new IntNode;
I have access to all of the member functions, both base and derived.
What is really the difference between these two statements? And when should they be used? And what shall I do in order to be access the member functions?
Cheers!