List, Iterators-conversion between types

0 Samiha Shaheed · March 1, 2015
list<string> L;
itr2 = ingredients.begin(); // string type
itr1 = units.begin(); // integer type

for ( ; itr2 != ingredients.end(); ++itr2){
L.push_back((string)(itr1)+(string)itr2); 
++itr1;
}

Post a Reply

Replies

Oldest  Newest  Rating
0 Samiha Shaheed · March 1, 2015
I am trying to convert (*itr1) which is integer, to a string. Then concatenate with *itr2 and push_back to list L. I know I forgot to add asterisk to deference them. I tried both ways, with and without dereferencing, it does not work. Some help would be appreciated.
  • 1

C++

107,320 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator