首页 > 解决方案 > 错误:在继承中使用已删除的函数

问题描述

我正在努力学习继承。我写了代码,在用 gcc6.3.0 编译时遇到了以下我从未见过的错误

class Book{
public:
    string title;
    string author;
    int page;

    Book(string Title, string Author, int Page){  
        title = Title;
        author = Author;
        page= Page;
    }

void setAuthor(string Author){
    author = Author;
}

string getAuthor(){
    return author;
}

string toString(){
    cout << "Title: " << title << "\nAuthor: " << author << "\nPage: " << page << endl;
}        

};

class SpecialEdtionBook : public Book{

public:
    void Special(){
        cout << "Special editions is out"<< endl;
    }

};

错误:test1.cpp:在函数“int main()”中:test1.cpp:47:23:错误:使用已删除的函数“SpecialEdtionBook::SpecialEdtionBook()”SpecialEdtionBook book2;

这个错误是什么意思?发生此类错误时我应该寻找什么?

标签: c++visual-c++

解决方案


推荐阅读