标签:
强制转换父类对象为子类
#include<iostream> #include<string> #include <typeinfo> using namespace std; class father{ public: void smart(){} virtual ~father(){} }; class son : public father { public: void say() { cout << "say" << endl; } }; void main() { father *p; p= new son; dynamic_cast<son*>(p)->say(); }
标签:
原文地址:http://www.cnblogs.com/siqi/p/4621375.html