-
Mulitple Inheritance
Hello there! My first post here.
I'm attempting to use static_cast to upcast a Base object (which gets downcast using dynamic_cast beforehand for storage in a container). It seems to work great on objects that are not involved in the multiple inheritance I have set up.
Code:
The inheritance:
Base
/ \
Derived Derived2
\ /
Derived3
Classes Derived and Derived2 are virtual to allow for the creation of Derived 3.
Any upcasting with static_cast seems to work with a derived class that is not involved in multiple inheritacne, and incidentally not virtual.
Does anyone have any pointers (ha!) for using static_cast (or any cast that will work) to return my dowcasted base object back to its proper derived class?
-
Code:
Classes Derived and Derived2 are virtual to allow for the creation of Derived 3.
By that, I'm assuming you mean that Derived3 inherits them virtually, not that Derived and Derived2 simply have virtual functions. Would you be able to show us the error that you get (or does the code just fail)?