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 循环中,访问迭代器 i 返回的字符串的 size() 成员函数时出现错误 ----> *i.size();
“类“std::_Vector_const_iterator>>”没有成员“大小”
最佳答案
(*i).size()
。 .
运算符的优先级高于 *
关于c++ - 获取迭代器返回的字符串的 size(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12769776/