The library that I use has many types, all of which come from the same two interfaces:
class Huey : public IDuck, public ICartoonCharacter
{
...
};
class Dewey : public IDuck, public ICartoonCharacter
{
...
};
class Louie : public IDuck, public ICartoonCharacter
{
...
};
I would like to store objects of all the above types in a wrapper class and insert objects of this wrapper class into a container. Of course, I would have to call methods belonging to both interfaces from my wrapper class.
What are my options here? I could think of
- save
IDuck *in my wrapper and dynamic_cast-ing before ICartoonCharacteror - using something like
boost::any, making my shell a class template, with a pair static_asserts, to ensure that the template parameter inherits from IDuckand ICartoonCharacter.
but none of the options, especially appeals. Any ideas?
, ? - , , 3 .
EDIT: , . public .
EDIT: dynamic_cast dynamic_cast ( ).
: , . , . !