3 回答
TA贡献1777条经验 获得超10个赞
virtualA::f()A::f()publicprotected
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贡献1797条经验 获得超6个赞
=0表示派生类必须提供实现,而不是基类不能提供实现。
TA贡献1757条经验 获得超7个赞
class Base {public:
virtual ~Base() = 0;};Base::~Base() {}class Derived : public Base {};int main() {
// Base b; -- compile error
Derived d; }- 3 回答
- 0 关注
- 366 浏览
添加回答
举报
