A
Alberto Luaces
Hi,
can I always rely on the behaviour shown in the code? (A pointer to a class
is always the same as the pointer obtained from its base class with RTTI)
#include <iostream>
class A{};
class B : public A {};
int main(){
B b;
std::cout << (&b == dynamic_cast<A*>(&b)) << "\n"; // Always true?
return 0;
}
Thank you,
Alberto
can I always rely on the behaviour shown in the code? (A pointer to a class
is always the same as the pointer obtained from its base class with RTTI)
#include <iostream>
class A{};
class B : public A {};
int main(){
B b;
std::cout << (&b == dynamic_cast<A*>(&b)) << "\n"; // Always true?
return 0;
}
Thank you,
Alberto