Hi.
I am new to c++ and programing in general and have run into a problem on one of my assignments. I am trying to insert one vector, into a certain spot in another vector. Both are of the same type <string>. My main problem is we have not really learned iterators, and my previous code sort of works around them. Is it possible to do this without iterators or what would be the easiest way to implement them into my code.
Sorry it this is not very clean. I used dev-c++ 4.9.9.2 to compile.
mMap is a mutli map where some keys have multiple elements to them
randIntInc is a sort of ghetto way of choosing a random element from each key.
sentence and terminalInsert are both vector<string>
getTokens(string x) is a function which parses a string(with spaces and multiple words) into a vector with 1 word per element. If you need to see the function just let me know, but I believe i found it on this site.
for(int j=0;j< sentence.size();j++)
{if (sentence[j][0]='<') // Checks to see if element in vector
// is non terminal
terminalInsert.clear(); //clears temporay vector used to insert
key=sentence[j]; //sets key to non terminal value form vector
itr1 = mMap.find(key); //sets multimap iterator to first key
randIntInc=rand()%(mMap.count(key)); //randomly choose element
for(int n=0; n<randIntInc; n++) //with key=key
{itr1++;}
terminalInsert=getTokens(itr1->second)//parses element from map
//into string vector
//for inserting into sentence
Thanks for takinga look and I apologize for how sloppy it is. If theres any questions let me know what else you need to know.