的代碼我試圖運行:不明白爲什麼我沒有被允許下標這一載體
std::string genBlankName(std::vector<Post> &posts)
{
std::string baseName = "New Post ";
int postNum = 1;
for (std::vector<Post>::iterator currentPost = posts.begin(); currentPost != posts.end(); currentPost++)
{
if (posts[currentPost].name.substr(0, baseName.length()) == baseName &&
utils::is_num(posts[currentPost].name.substr(baseName.length(), std::string::npos)) &&
utils::to_int(posts[currentPost].name.substr(baseName.length(), std::string::npos)) > postNum)
{
postNum = utils::to_int(posts[currentPost].name.substr(baseName.length(), std::string::npos));
}
}
return baseName + utils::to_string(postNum);
}
和錯誤,我得到:
/home/brett/projects/CLPoster/CLPoster-build-desktop/../CLPoster/item.h:240: error: no matching function for call to
std::vector<cl::Post, std::allocator<cl::Post> >::at(__gnu_cxx::__normal_iterator<cl::Post*, std::vector<cl::Post, std::allocator<cl::Post> > >&)
對不起,不說更多,但我認爲這是一個很普遍的事情,我只是不知道作爲一個結局。我會谷歌它,但它似乎過於普遍的問題,使任何有用的,因爲我懷疑這是更多的問題與我的實施或沿着這些線路。
Aww該死的,17秒! – Xeo 2011-02-11 14:23:57
@Xeo:提高你的打字技巧:-D – 2011-02-11 14:34:54