Jelean Thomas
Jelean Thomas

Reputation: 422

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;
}

Upvotes: 2

Views: 9471

Answers (1)

Wintermute
Wintermute

Reputation: 44023

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. In the same vein, replace itr.length() with itr->length().

Upvotes: 9

Related Questions