Multiple inheritance
I have hierarchy, that contains one base interface class -
IConnection,
and two derived interfaces: IClientConnection and IServerConnection
=================
class IConnection
{
public:
virtual void Send() = 0;
};
class IClientConnection : public virtual IConnection
{
public:
virtual void Connect() = 0;
};
class IServerConnection : public virtual IConnection
{
public:
virtual void Accept() = 0;
};
=================
I also have a realization for base interface
=================
class Connection : public virtual IConnection
{
public:
virtual void Send()
{
//...
};
};
=================
For two other interfaces I want to use existing realization of base
interface.
=================
class ServerConnection : public IServerConnection,
piblic Connection
{
public:
virtual void Accept();
};
=================
I inherit Connection, because I don't want to duplicate the code from
Connection::Send();
When I compile this code with Microsoft compiler, I get following
errors:
warning C4250: 'ClientConnection' : inherits
'Connection::Connection::Send' via dominance.
Is there a better way of doing this? How can I avoid multiple
inheritance and code duplication?
I really like an idea of such inheritance. Why is it bad?
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]