Inheritance from base class with reference
I have 3 classes :
- Server : public Tcp_Object
- Server_Client : public Tcp_Object
What I want is to be able for calling parent's methods. For ex.
How should I do that? I would make constructor to pass reference to object which is calling for that and save it. But what if I create Server object which have no parent?
- Server_Client has parent of class Server
- Server object doesn't have any parent
Here is some of my code so far :
Tcp_Object::Tcp_Object(Tcp_Object& parent): _parent(parent)
//Looks ok I guess
Tcp_Object::Tcp_Object(): _parent( )
//But what if I dont have parent and I have to pass init this reference?
Server::Server(int port): Tcp_Object()