Is there anything wrong with the following code? In particular I'm interested in the use of reinterpret_cast
.
class Base1
{
public:
virtual void foo(){}
};
class Base2
{
public:
virtual void bar(){}
};
class Derived : public Base1, public Base2
{
};
int main()
{
Base1* instance1 = new Derived();
instance1->foo();
Base2* instance2 = reinterpret_cast<Base2*>(instance1);
instance2->bar();
return 0;
}