簡體   English   中英

的std ::矢量 <std::basic_string<char> &gt; :: const_iterator&#39;沒有名為&#39;c_str&#39;的成員

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM