numElements--;/// well this just decrements the number of elements, it doesn't do the real popping
///don't you think so
For this case , popping your elements would be a very costly process, copying ,deleting , and creating a new array ..just for the purpose of deleting a single elements is a really big deal, I would advice you to switch to linked lists, they just involve manipulating several pointers , don't you think that is a bit reasonable .
I completely agree with you, this is what is required from the text. So I need a way to just use pop_back in this form, linked lists are in the next chapter of my text.
The function
void pop_back().
This function removes the last integer pushed into the vector. The size of the vector is reduced by one. The function does nothing if the vector is empty.
The function
int last().
This function returns the value of the last integer pushed into the vector, but it does not remove it. Do not worry about the case where the vector is empty.
The function
operator[](int).
This function overloads the [ ] operator we use to index into an array. If you need help understanding how to do this, review the chapter on operator overloading in Big C++.
so will settle for arrays as in your current code or will you switch to linked list.
If you insist to stick to arrays you would have to:-
1. Create a dynamic array with size less than one.
2. Copy all elements ignoring the last one.
3. Decrement the element counter bu one
4. Delete the old array.
Thanks for laying that out for me, I am not certain how to start with something like that within my template implementation for pop_back. I will continue research, if you have any other suggestions please let me know.