在使用std :: list :: iterator的行中,编译器给出了一条消息“错误:不允许使用类限定名.我不确定是什么问题?有人可以使用我的代码扩展编译器问题.
#include <iostream> #include <list> using std::cout; using std::endl; using std::list; using std::list<int>::iterator; int main( ) { list<int> listObject; for (int i = 1; i <= 3; i++) listObject.push_back(i); cout << "List contains:\n"; iterator iter; for (iter = listObject.begin( ); iter != listObject.end( ); iter++) cout << *iter << " "; cout << endl; cout << "Setting all entries to 0:\n"; for (iter = listObject.begin( ); iter != listObject.end( ); iter++) *iter = 0; cout << "List now contains:\n"; for (iter = listObject.begin( ); iter != listObject.end( ); iter++) cout << *iter << " "; cout << endl; return 0; }