c++虚函数调用及使用
#include <iostream> using namespace std; class A { public: virtual int print()=0; }; class B: public A { public: virtual int get()=0; virtual int print() { cout<<get()<<endl; } }; class C: public B { public: int get() { return 100; } }; int func(A* a) { a->print(); } int main() { C c; func(&c); return 0; }