2、虚拟机制是如何实现的,参见Inside the C++ Object Model ,Addison Wesley 1996)//---------------------------------------------------------class Base{public:Base(){}public: virtual void print(){cout<<"Base";}}; class Derived:public Base{public:Derived(){}public: void print(){cout<<"Derived
3、";}}; int main(){ Base *point=new Derived(); point->print();} //---------------------------------------------------------Output:Derived //---------------------------------------------------------这也许会使人联想到函数的重载,但稍加对比就会发现两者是完全不同的:(1) 重载的几个函数必须在同一个类中;覆盖的函数必须在有继承关系的不同的类中文章内容版