I have a textbook question that's a two parter, the first part asks me to write the definition for a sumStack function (conceptually) with the prototype as:
void sumStack(stack<int> istack)
I can do that part simply enough, by having it pop each value of the stack and adding that value to a sum, but then it asks me why if I called it in the application like this:
total = sumStack(mystack)
Why would mystack still have the values it started with?
Is it because its a void function and that all the 'popping' is done to a copy? And/or because mystack is passed by value? Any help would be appreciated!