Okay, you have written some code and it doesn't do what you want or - as in your case - doesn't even compile. In this case you need to run your program in a debugger or understand the error messages the compiler is giving you. That is not easy when you are doing it the first time, but it will become easier with some practice. Googling for others that ran into the same trouble will not help you.
That said, let's start systematically. First start be re-reading your course notes and understanding them FULLY. You might even get a wider perspective by reading articles like this one
Merge sort - Wikipedia, the free encyclopedia[
^].
I won't do the work for you, as this is certainly an exercise and you should learn by doing it. But I am going to give you a couple of hints:
void merge(vector<int> aVector, int size, int low, int middle, int high)
</int>
The size argument is actually superfluous. aVector can tell you its size by the size() member function. By passing the size a second time gives only room to make mistakes.
{
int temp[size];
This will not work. It won't even compile. And it certainly is not very efficient. If you need a temporary array (and you do for the merge sort algorithm), better allocate it once in your mergeSort function and pass it to every call of merge. You may use another vector<int> for the temporary array.
int middle = (low + high) / 2;
mergeSort(aVector, size, low, middle);
mergeSort(aVector, size, middle+1, high);
Use the same conventions throughout your program. You started by defining low as the first element of the range and high as the first element
beyond the range. That is a very common practice in C / C++. Now look at your definition of middle: The first call to mergeSort will sort that range from low up to
and not including middle. You see where you made a mistake?
Take a look at all of your loops and check whether they should up and including or excluding the final value, i.e. whether you need to compare with <= or <. Double check each and every loop!
Run your program in a debugger and stop at every single statement. Check whether your program did exactly what you expected it to do by looking at the variables.
I hope these hints will get you on the right way.