#include using namespace std; class A { public: int x; void show() { cout << "A show() x = " << x << endl; } }; class B { public: int x; void show() { cout << "B show() x = " << x << endl; } }; int main() { A *a = new A(); a->x = 100; B *b = new B(); b->x = 200; // B *b2 = static_cast(a); // error // B *b3 = dynamic_cast(a); // error B *b4 = reinterpret_cast(a); // 输出: B show() x = 100 b4->show(); return 0; }