摘要:
RTTI、dynamic_cast、typeid、虚函数表 RTTI(Run Time Type Identification):运行时类型识别 > 基类中必须至少要有一个虚函数 Human * phuman = new Men; Human& q = *phuman; 通过运行时类型识别,程序能够 阅读全文
摘要:
多态 基类指针 // 父类指针可以 new 一个子类对象 Human *pman = new Man(); Human *pwman = new Wonan(); 抛出问题:父类指针没有办法调用子类的成员函数,那么你为什么还让父类指针 new 一个子类对象呢? 下面与虚函数搭配 虚函数(动态绑定) 阅读全文