[英]std::vector<std::basic_string<char> >::const_iterator’ has no member named ‘c_str’
i have problem with this. 我有这个问题。 It says this:
它说:
‘std::vector<std::basic_string<char> >::const_iterator’ has no member named ‘c_str’
Could you help me, please ? 请问你能帮帮我吗 ?
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;
}
Instead of 代替
itr.c_str()
write 写
itr->c_str()
Because c_str
is a member not of the iterator but of the std::string
it refers to. 因为
c_str
不是迭代器的成员,而是它所引用的std::string
的成员。 In the same vein, replace itr.length()
with itr->length()
. 同样,用
itr->length()
替换itr.length()
itr->length()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.