[英]cpp: error: 'class boost::optional<std::__cxx11::basic_string<char> >' has no member named 'c_str'
[英]std::vector<std::basic_string<char> >::const_iterator’ has no member named ‘c_str’
我有这个问题。 它说:
‘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;
}
代替
itr.c_str()
写
itr->c_str()
因为c_str
不是迭代器的成员,而是它所引用的std::string
的成员。 同样,用itr->length()
替换itr.length()
itr->length()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.