I'm trying to make a function that takes a reference to a vector as an argument, and reverses its elements. This is my code:
1 2 3 4 5 6 7
void ref_reverse(vector<int>& vect)
{
for(int i = 0; i <= (vect.size() / 2); i++)
{
swap(vect[i], vect[(vect.size()-i)]);
}
}
I got an error message when running the program: "Debug Error! R6010 abort() has been called". I can't figure out what is wrong. If anyone could help me understand what is wrong with my code, I would appreciate it.