继承有问题。我不知道脚本有什么问题..
主 中的
CSVDoglist.h FileAdoptionList.h AdoptionList.h 错误: 我已经阅读了有关此问题的更多主题,但我没有找到解决方案。 有人能帮助我吗?感谢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;
}
class CSVDoglist : public FileAdoptionList
{
public:
void writeToFile();
void displayAdoptionlist() const;
};
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;
};
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() {}
};
object of abstract class type "CSVDoglist" is not allowed:
'CSVDoglist': cannot instantiate abstract class Adoptig Dogs
答案 0 :(得分:3)
好像你有一个错字。
名为displayAdoptionlist
的函数(包含小l
)在CSVDoglist
中声明,但纯虚函数displayAdoptionList
(包含大L
)isn&# 39; t覆盖在CSVDoglist
。