#include using namespace std;//不知道为什么事实上非常好解释的东西在网上搞的人晕头转向的,下面是我的理解。
class Base { public: virtual void PrintfName() = 0; virtual void PrintfSchool() = 0; }; class Student1 : public Base { public: void PrintfName() { cout << "Student1Name"<< endl; } void PrintfSchool() { cout << "Student1School"<<endl; } }; class Student2 : public Base { public: void PrintfName() { cout << "Student2Name"<< endl; } void PrintfSchool() { cout << "Student2School"<< endl; } }; class Direver { public: Direver(Base *base) { pbase = base; } void Construct() { pbase->PrintfName(); pbase->PrintfSchool(); } private: Base *pbase; }; int main() { Direver d(new Student2()); d.Construct();
return 0; }