简体   繁体   English

C++ 错误:不允许抽象类类型的对象

[英]C++ error: object of abstract class type is not allowed

Having trouble with inheritance.继承有问题。 I do not know what is wrong with the script..我不知道脚本有什么问题..

in main在主要

int main(){
    Repository repo("dogs.txt");
    FileAdoptionList* a = new CSVDoglist{}; / here is the error
    Controller ctrl(repo, dogValidator{}, a);
    UI ui(ctrl);

    ui.startUI();

    delete a;
}

CSVDoglist.h CSVDoglist.h

class CSVDoglist : public FileAdoptionList
{
public:

    void writeToFile();
    void displayAdoptionlist() const;
};

FileAdoptionList.h文件收养列表.h

class FileAdoptionList : public AdoptionList
{
protected:
    std::string filename;

public:
    FileAdoptionList();
    virtual ~FileAdoptionList() {}

    void setFilename(const std::string& filename);
    virtual void writeToFile() = 0;
    virtual void displayAdoptionList() const = 0;
};

AdoptionList.h收养清单.h

class AdoptionList
{
protected:
    std::vector<Dog> storage;

public:
    AdoptionList();

    // Adds a dog to the playlist.
    void add(const Dog& dog);
    // Checks if the adoptionlist is empty.
    bool isEmpty();

    virtual ~AdoptionList() {}
};

ERRORS:错误:

object of abstract class type "CSVDoglist" is not allowed:  

'CSVDoglist': cannot instantiate abstract class Adoptig Dogs    

I have read more topics about this problem but I didn't found the solution.我已阅读有关此问题的更多主题,但没有找到解决方案。

Can someone help me?有人能帮我吗? Thanks谢谢

It seems you have a typo.看来你打错了。

A function named displayAdoptionlist (contains small l ) is declared in CSVDoglist , but the pure virtual function displayAdoptionList (contains large L ) isn't overrided in CSVDoglist .CSVDoglist声明了一个名为displayAdoptionlist (包含小l )的CSVDoglist ,但纯虚函数displayAdoptionList (包含大L )在CSVDoglist没有被覆盖。

暂无
暂无

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

相关问题 C++ - 不允许抽象类类型的对象 - C++ - Object of abstract class type is not allowed 不允许使用抽象类类型为“动物”的对象:(C ++) - Object of abstract class type “Animal” is not allowed: (C++) C ++错误:不允许抽象类类型的对象:纯虚函数没有覆盖 - C++ error: object of abstract class type is not allowed: pure virtual function has no overrider C ++中不允许使用抽象类型为“ NumericQuestion”的对象 - object of abstract type “NumericQuestion” is not allowed in c++ 错误:不允许使用抽象类类型的对象 - Error: Object of abstract class type is not allowed xcode C ++错误:分配抽象类类型为&#39;Grain&#39;的对象 - xcode c++ error: allocating an object of abstract class type 'Grain' C++ object of abstract class type "mazeGenerator" is not allowed: pure virtual function "olcGameEngine::OnUserUpdate" has no overrider - C++ object of abstract class type "mazeGenerator" is not allowed: pure virtual function "olcGameEngine::OnUserUpdate" has no overrider C++ 问题:不允许抽象 class 类型“经理”的对象 - C++ question: Objects of abstract class type "manager" are not allowed 不能分配抽象类型的对象 - 但是类不是抽象的! (C ++) - cannot allocate object of abstract type - but the class is not abstract! (C++) 错误:创建抽象类的实例时,不允许使用抽象类类型的对象 - Error: object of abstract class type is not allowed when create an instance of a abstract class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM