3 回答
TA贡献1860条经验 获得超8个赞
virtual
A::f()
A::f()
public
protected
class B : public A { virtual void f() { // class B doesn't have anything special to do for f() // so we'll call A's // note that A's declaration of f() would have to be public // or protected to avoid a compile time problem A::f(); }};
TA贡献1900条经验 获得超5个赞
=0表示派生类必须提供实现,而不是基类不能提供实现。
TA贡献1856条经验 获得超5个赞
class Base {public: virtual ~Base() = 0;};Base::~Base() {}class Derived : public Base {};int main() { // Base b; -- compile error Derived d; }
- 3 回答
- 0 关注
- 708 浏览
添加回答
举报