嗨,我从以下代码中收到编译错误。我无法弄清楚:
g++ stl_list_1.cc
stl_list_1.cc: In function \u2018int main()\u2019:
stl_list_1.cc:16: error: \u2018struct std::_List_iterator<int>\u2019 has no member named \u2018clist\u2019
stl_list_1.cc:19: error: \u2018struct std::_List_iterator<int>\u2019 has no member named \u2018clist\u2019
stl_list_1.cc:25: error: no match for call to \u2018(std::list<std::_List_const_iterator<int>, std::allocator<std::_List_const_iterator<int> > >) (int&)\u2019
代码:
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
main()
{
std::list<int> clist;
for (int i =0; i<10; i++)
{
clist.push_back(i);
}
std::list<std::list<int>::const_iterator> list1;
std::list<int>::iterator itr1;
itr1 = std::find(clist.begin().clist.end(),1);
std::list<int>::iterator itr2 ;
itr2 = std::find(clist.begin().clist.end(),7);
list1.push_back(itr1);
list1.push_back(itr2);
for(int j =0; j< list1.size(); j++)
{
int k = *list1[j];
std::cout << "cvalue " << k <<std::endl;
j++;
}
}
谢谢鲁奇