4
嘿,我已經覆蓋operator<<
,當我試圖打印方法(常量)我得到一個錯誤的使用方法:如何重載operator <<?
在被覆蓋的運營商:
ostream& operator <<(ostream& os, Date& toPrint)
{
return os << toPrint.GetDay() << "/" << toPrint.GetMonth() << "/" << toPrint.GetYear();
}
在那裏我嘗試使用它:
void TreatmentHistory::TreatmentHistoryPrint() const
{
cout << m_treatmentDate << "\n" << endl;
}
你會得到什麼錯誤? – SLaks 2010-09-14 23:43:58
<< m_treatmentDate之前的紅線,當我踩着它時,錯誤是:沒有運算符「<<」匹配這個操作數。 – 2010-09-14 23:45:25