Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在超类中声明了一个虚拟方法。我想使用指向子类对象的超类指针调用该方法。例如:
class A { virtual void foo(); } class B : public A { virtual void foo(); } A *b = new B();
这种方法很好,但是- 要调用它,它需要A::foo()是.privatepublic
A::foo()
private
public
您还缺少;类定义之后的实现和尾随。
;