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;
}
Run Code Online (Sandbox Code Playgroud)
在for循环中,我在访问迭代器返回的字符串的size()成员函数时遇到错误i ---->*i.size();
"class"std :: _ Vector_const_iterator >>"没有成员"大小"
| 归档时间: |
|
| 查看次数: |
2865 次 |
| 最近记录: |