C++ 中const修饰虚函数实例详解
【1】程序1
#include <iostream> using namespace std; class Base { public: virtual void print() const = 0; }; class Test : public Base { public: void print(); }; void Test::print() { cout << "Test::print()" << endl; } void main() { // Base* pChild = new Test(); //compile error! // pChild->print(); }