|
From: Ioannis V. <no...@ya...> - 2001-10-20 16:22:49
|
Strange effect. Consider the code:=20
=20
#include <iostream>
=20
class A
{
public:
void test() { std::cout<<"A!\n"; }
};
=20
class C: public A
{
public:
void test() { std::cout<<"C!\n"; }
};
=20
=20
=20
int main()
{
using namespace std;
=20
A a;
=20
C *cp=3Dstatic_cast<C *>(&a);
=20
cp->test();
=20
}
=20
=20
It produces
=20
C:\c>temp
C!
=20
Isn't this wrong? I expected either a GPF or garbage, or even "A!" but
not "C!".
=20
=20
Ioannis
=20
* Ioannis Vranos
* Programming pages: http://www.noicys.f2s.com
<http://www.noicys.f2s.com/>=20
* Alternative URL: http://run.to/noicys
=20
|