【C++编程】调用基类的虚函数
调用基类的虚函数
代码实现:
#include <iostream>
class Base {
public:
virtual void f() { std::cout << "Base::base()" << std::endl; }
};
class Test : public Base {
public:
void f() { std::cout << "Test::test()" << std::endl; }
};
int main()
{
Base *b = new Test();
b->Base::f();
b->f();
}