How do I push an object to the front fo an C++ STL vector?
Posted on 2007-07-26
I've been using the C++ STL vector class for years but I still need to get more familiar with it. I always use the push_back() function, but can't seem to find an equivalent push_front() function (at least push_front is not in my Borland C++ documentation). If someone can show me how to push to the front of a vector (both with and without using iterators), you get 500 points. For the iterator solution, you will probably need to use the insert() function.
NOTE: The solution must push an object--not a scalar type. Just make a simple class with, say, two attributes.