好的,所以我首先開始學習C#,現在我正在學習C++,所以我對它很陌生。
在C#中,當我想要訪問列表中的列表時,我只需要使用嵌套for-each循環。如何訪問C++列表中的列表?
現在,因爲在C++中我不知道如何使用for-each循環,我嘗試使用for循環訪問嵌套列表。
這裏是我的代碼:
int main
{
list<list<char *> > moves;
list<char *> pointers;
list<list<char> > undoValues;
list<char> undoValue;
for(list<list<char *> >::iterator outer=moves.begin();outer!=moves.end();outer++)
{
for(list<char *>::iterator inner=outer.begin();inner!=outer.end();inner++)
{
}
}
}
我得到2個錯誤:
error 'struct std::_List_iterator<std::list<char*>,std::allocator<char *> > >' has no member named begin
error 'struct std::_List_iterator<std::list<char*>,std::allocator<char *> > >' has no member named end
如何訪問嵌套列表?
+1列出了兩種可能性。 – egrunin 2012-07-19 14:39:09