![](/img/trans.png)
[英]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.