获取迭代器返回的字符串的大小()

时间:2012-10-07 14:42:28

标签: c++ visual-c++

vector<string> frame(const vector<string>& v){
   vector<string> ret;
   string::size_type maxlen = width(v);
   string border(maxlen + 4,'*');

   //write the top border
   ret.push_back(border);

  //write each interior row
  for(vector<string>::const_iterator i = v.begin();i != v.end();++i){
     ret.push_back("* " + *i + string(maxlen- (*i.size()),' ') + " *");
  }

  //write the bottom border
  ret.push_back(border);

  return ret;
 }

在for循环中,我在访问iterator i返回的字符串的size()成员函数时遇到错误----&gt; * i.size();

“class”std :: _ Vector_const_iterator&gt;&gt;“没有会员”尺寸“

1 个答案:

答案 0 :(得分:7)

(*i).size().运算符的优先级高于*