我有这个问题。它说:
‘std::vector<std::basic_string<char> >::const_iterator’ has no member named ‘c_str’
请问你能帮帮我吗?
for ( ObjectMgr::WayContainer::const_iterator itr = Ways.begin(); itr != Ways.end(); ++itr )
{
char *cstr = new char[itr.length() + 1];
strcpy(cstr, itr.c_str());
if ( !stricmp(cstr, wayss) )
{
return;
}
delete [] cstr;
}
答案 0 :(得分:9)
而不是
itr.c_str()
写
itr->c_str()
因为c_str
不是迭代器的成员,而是它引用的std::string
的成员。同样,将itr.length()
替换为itr->length()
。