#include <iostream> using namespace std; class A { public: void f() { cout << "AAAAAAAAAA" << endl; } }; class B :public A { public: virtual void f() { cout << "BBBBBBBBBBB" << endl; } }; int main() { A *a = new B(); a->f(); return 0; }
时间: 2025-01-01 23:56:02