纯虚函数
#include <iostream> namespace Virtual { class CBase { public: CBase() {} virtual ~CBase() {} void testBase() { print(); } virtual void print() = 0; }; class CDived : public CBase { public: CDived() {} ~CDived() {} void testDived() {testBase();} void print() {std::cout << "CDived's print() is called!\n";} }; void fun() { CDived p; p.testDived(); } }