#include<iostream>
struct I1
{
virtual void nb1()=0;
virtual ~I1(){}
};
struct I2
{
virtual void nb2()=0;
virtual void nb22()=0;
virtual ~I2(){}
};
struct C12 : I1, I2
{
virtual void nb1(){std::cout << "nb\n";}
virtual void nb2(){std::cout << "nb2\n";}
virtual void nb22(){std::cout << "nb22\n";}
};
int main()
{
I2 * p2 = new C12;
I1 * p1 = reinterpret_cast<I1*>(p2);
return 1;
}
Is there any contraindications to use a reinterpret_cast here ? Should I mandatory use dynamic_cast?
Is it ok ONLY if I1 and I2 are pure virtual ?
I1andI2are unrelated?even thoughreinterpret_castis specifically for these conversionscharto a function pointer with this cast rite?(obviously moronic:-))