'Toxin
2012-01-26 18:30:56
So this is literally driving me up the wall, and I simply do not know what I need to do in order to do this….
Anyway, this is in relation to a programming assignment, assigned by one of my professors who likes cutting lectures more than 1/2 so we basically don't know anything and must use the internet for references.
We're asked to use vectors only.
So, I have defined a new vector of strings…
Now, we have to be able to do certain things with this vector of strings, such as adding elements to the back and FRONT of the vector. I know, I know… c++ has a library of vectors which I am using and utilizing the push_back method to add the strings to the back of the vector, however I am having a hard time with doing the same thing, except for dealing with the front of the vector.
Function for adding a string into the vector's backend :
Now, how on EARTH do I do this for adding a string to the first element of the vector?
Note: The vector has an undetermined size throughout the whole program, such that the user can continuously add strings to the front or the back of it.
Anyway, this is in relation to a programming assignment, assigned by one of my professors who likes cutting lectures more than 1/2 so we basically don't know anything and must use the internet for references.
We're asked to use vectors only.
So, I have defined a new vector of strings…
typedef std::vector<std::string> programString;
Now, we have to be able to do certain things with this vector of strings, such as adding elements to the back and FRONT of the vector. I know, I know… c++ has a library of vectors which I am using and utilizing the push_back method to add the strings to the back of the vector, however I am having a hard time with doing the same thing, except for dealing with the front of the vector.
Function for adding a string into the vector's backend :
programString push(string theString, programString z)
{
string temp = theString;
z.push_back(theString);
return z;
}
Now, how on EARTH do I do this for adding a string to the first element of the vector?
Note: The vector has an undetermined size throughout the whole program, such that the user can continuously add strings to the front or the back of it.