Archived
This forum has been archived. Please start a new discussion on GitHub.
Implementing multiple interfaces in a single C++ class
sidney
in Help Center
Hi all,
I was wondering if it was possible to implement more than one interface in as single C++ class, for example using multiple inheritance:
I cannot get this to work, gcc complains that there is "no unique final overrider" for a number of items, such as ice_id(), ice_clone(), and ice_ping().
Is there no way in which this can be made to work? What are the best alternatives here? Right now I'm thinking of making an aggregate class like this:
Is that the way to go, or are there better alternatives?
Best regards Sidney
I was wondering if it was possible to implement more than one interface in as single C++ class, for example using multiple inheritance:
class ABReceiverI: public virtual AReceiver, public virtual BReceiver
{
virtual void receiveA(A itemA);
virtual void receiveB(B itemB);
};
I cannot get this to work, gcc complains that there is "no unique final overrider" for a number of items, such as ice_id(), ice_clone(), and ice_ping().
Is there no way in which this can be made to work? What are the best alternatives here? Right now I'm thinking of making an aggregate class like this:
class ABReceiver
{
class AReceiverI
{
};
class BReceiverI
{
};
};
Is that the way to go, or are there better alternatives?
Best regards Sidney
0
