1 class base{ 2 public: 3 virtual void f(int n){ cout << "base"<f(2);18 b->f(2.0);19 Derived *d = &de;20 d->f(2.0);21 d->f(2);22 }
输出为:override override overload override
如果子类没有重写基类的虚函数,输出为 base base overload overload
本文共 320 字,大约阅读时间需要 1 分钟。
1 class base{ 2 public: 3 virtual void f(int n){ cout << "base"<f(2);18 b->f(2.0);19 Derived *d = &de;20 d->f(2.0);21 d->f(2);22 }
输出为:override override overload override
如果子类没有重写基类的虚函数,输出为 base base overload overload
转载于:https://www.cnblogs.com/hchacha/p/7655982.html