c++迭代器使用问题

#include <stdafx.h>#include<iostream>#include <iomanip>#include <string>#include <cctype>#include <vector>using namespace std;int b=0;int main(){ int i=0; vector<string> text; string copy; while(cin>>copy)   text.push_back(copy); for(vector<string>::iterator iter=text.begin();iter!=text.end();iter++) {  for(;(*iter)!=(*iter).end();(*iter)++)  if(islower(**iter))   (**iter)=toupper(**iter);  cout<<*iter<<" ";  if((i+1)%8==0)   cout<<endl;  i++; } system("pause");                             return 0;}应该是第2个循环错了,我想试试迭代器能不能像指针那样**iter用,但编译同不过谁帮忙解决下代码哪出问题了,求大神解答!!万分感谢

第1个回答  2011-11-21
迭代器就就是指针概念的扩展。(*iter)!=(*iter).end();错误应该在这里,*iter是一个字符串,(*iter).end()的字符串的尾迭代器。**iter还有这个,*iter是string,**iter是*string,没有意义!别的我就没看了,代码太乱了。