MyTask.h虛函數解析的外部錯誤
class MyTask
{
virtual std::ostream& show(std::ostream &os) const ;
};
MyTask.cpp
std::ostream& MyTask::show(std::ostream &os) const
{
os << "Task(" << this->id << "):\t Processing time:" << this->p << "\t Weight:"<< this->w ;
return os;
}
我得到一個未解決的外部鏈接錯誤,當我添加在頭文件虛擬字。我已經檢查過類似的問題,但問題是該函數未定義,或者它不是純虛擬的。
編輯: 確切的錯誤是:
MiniOS.obj : error LNK2001: unresolved external symbol "public: virtual class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall SimOS::MyTask::show(class std::basic_ostream<char,struct std::char_traits<char> > &)const " ([email protected]@[email protected]@[email protected][email protected]@[email protected]@@[email protected]@[email protected]@Z)
所以我覺得這個問題是別的東西,任何想法?
錯誤的確切描述是什麼? –
我添加了確切的描述,謝謝。 –
@YochaiTimmer我這樣做,它不工作:( –