#include "stdafx.h" #include#include using namespace std; class A { public: virtual void foo() { cout<<"A foo"< FunctionB(); pb=dynamic_cast(pa); if(pb==NULL) { cout<<"The pointer pb is null"< (pa))->FunctionB(); (dynamic_cast(pa))->foo(); //執行出錯,因為需要this指針 (dynamic_cast(pa))->show(); //執行出錯,因為需要this指針 system("pause"); return 0; }