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();
}

 

dd 读的

posted @ 2022-04-12 10:55  苏格拉底的落泪  阅读(210)  评论(0编辑  收藏  举报