A pointer to a base class is not necessarily equal to a pointer to a
class derived from it. You could see the free item 27 of Effective C++
3rd edition for an explanation.
Fraser.
"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
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com