C ++ templates and inheritance
Let's say I have a simple template server that takes a client as a template argument:
template<class T>
class Server<T>{
Server(int port);
}
and for the Client something like this is defined:
class Client{
Client(Server<Client> *server, // <--
int socket);
};
But I also want to say that the class User
inherits from Client
( class User : public Client
), so I could do Server<User>
instead Server<Client>
. class User
obviously needs to be passed Server<Client>
as a parameter when building Client
. However, with the current implementation, this seems impossible.
How should I approach this problem?
source to share