简体   繁体   English

创建派生类的对象时给出错误的抽象类

[英]Abstract class giving error while creating object of derived class

class base
{
    public:
    virtual void display() = 0;
};

class derived : public base
{
    void display()
    {
        //print display of derived//some code
    }
};

int main() {
    derived d;
}

When I run the above code, it gives an error that I can't create an object of abstract class; 当我运行上面的代码时,它给出一个错误,即我无法创建抽象类的对象。 however, my derived class is not a abstract class. 但是,我的派生类不是抽象类。

Can anyone explain why there is an error? 谁能解释为什么有错误?

You have an extra {. 您还有一个额外的{。 public base { { 公共基础{

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM