LessonInterfaceC++接口在STL ::列表
class ILesson
{
public:
virtual void PrintLessonName() = 0;
virtual ~ILesson() {}
};
STL容器
typedef list<ILesson> TLessonList;
調用代碼
for (TLessonList::const_iterator i = lessons.begin(); i != lessons.end(); i++)
{
i->PrintLessonName();
}
錯誤:
Description Resource Path Location Type passing ‘const ILesson’ as ‘this’ argument of ‘virtual void ILesson::PrintLessonName()’ discards qualifiers
雖然這是真的,但錯誤信息插孔已粘貼不是由於此錯誤。 – sbi 2009-10-21 15:18:57
嘗試和錯誤是: 說明\t \t資源路徑\t \t位置類型 請求構件 'PrintLessonName' 在 '* i.std :: _ List_const_iterator <_Tp> ::操作符 - > [與_TP = ILesson *]()',這是非類類型'ILesson * const' – 2009-10-21 15:19:08
我沒有觀察到const問題,我的眼睛第一次落在'typedef list TLessonList;'。無論如何,他還必須解決這個問題。 –
AraK
2009-10-21 15:21:02