Вот, еще один показательный пример, кастинг специально сдела в «C» стиле, дабы не было мыслей, что это особенность только dynamic_cast-а:
#include <stdio.h>
class A
{
int a;
public:
A() {}
virtual ~A() {}
};
class B
{
int a;
public:
B() {}
virtual ~B() {}
};
class C : public A, B
{
int a;
public:
C() {}
virtual ~C() {}
};
int main()
{
C *c = new C();
printf("%p\n%p\n%p\n",
c,
(A*)c,
(B*)c);
}
Вывод:
$ ./1
0x100100080
0x100100080
0x100100090
$ g++ --version
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.