So the code is
class A
{
public:
int i;
A(){
i = 5;
}
};
class B : public A
{
public:
void someFunc();
};
class C
{
A myObj;
public:
void func(){
B* foo = reinterpret_cast<B*>(&myObj);
foo->someFunc();
}
};
Assuming that classes will stay as they are and never change, is this use of reinterpret_cast correct(i think that it's not)? If not, which exact parts of C++ standard(you can use any edition) are violated here?
Aucun commentaire:
Enregistrer un commentaire