list iterator的用法
//头文件
typedef struct tagCard
{
char *face;
char *suit;
}Card;
typedef list<Card> oneGamerCardsList;
typedef list<oneGamerCardsList> AllGamersCardsList;
class CardClass
{
..........
void Dis(void) const;
private:
oneGamerCardsList mOneGamerCardsList;
AllGamersCardsList mAllGamersCardsList;
};
//实现文件
void CardClass::Dis(void) const
{
list<Card>::iterator oneItr;
list<oneGamerCardsList>::iterator allItr;
for (allItr = mAllGamersCardsList.begin(); allItr != mAllGamersCardsList.end(); ++allItr)
{
for (oneItr = allItr->begin(); oneItr != allItr->end(); ++oneItr)
{
cout<<oneItr->face<<"---"<<oneItr->suit<<endl;
}
cout<<"---------------------------"<<endl;
}
}
//编译错误
d:\vc2008_demo\projects_win32app\game001\game001\game001.cpp(65) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::list<_Ty>::_Const_iterator<_Secure_validation>' (or there is no acceptable conversion)
with
[
_Ty=oneGamerCardsList,
_Secure_validation=true
]
c:\program files\microsoft visual studio 9.0\vc\include\list(427): could be 'std::list<_Ty>::_Iterator<_Secure_validation> &std::list<_Ty>::_Iterator<_Secure_validation>::operator =(const std::list<_Ty>::_Iterator<_Secure_validation> &)'
with
[
_Ty=oneGamerCardsList,
_Secure_validation=true
]
while trying to match the argument list '(std::list<_Ty>::_Iterator<_Secure_validation>, std::list<_Ty>::_Const_iterator<_Secure_validation>)'
with
[
_Ty=oneGamerCardsList,
_Secure_validation=true
]
Build log was saved at "file://d:\vc2008_Demo\Projects_win32App\Game001\Game001\Debug\BuildLog.htm"
Game001 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
//为什么为这样? 错在哪里?
//请高手指点!