這是我的代碼的一部分:C++構造錯誤
virtual bool operator==(const File& file) const = 0;
和.cpp文件
bool File::operator==(const File& file) const {
return true;
}
我得到這個編譯錯誤:在.h文件 宣言
1>c:\users\talw\desktop\hw5\hw5\project1\main.cpp(76): error C2259:
'Directory' : cannot instantiate abstract class
1> due to following members:
1> 'bool File::operator ==(const File &) const' : is abstract
1> c:\users\talw\desktop\hw5\hw5\project1\file.h(57) : see
declaration of 'File::operator =='
請幫忙。 謝謝
我沒有看到構造函數...? –
該類是抽象的,所以刪除= 0位 –
所以...爲什麼你把'= 0'在運算符聲明? – AnT