I read everywhere that back() function return reference to the last element, but I have a doubt.
I created a vector with elements 1,3,5 resp.Then I wrote the following code
int i = v.back();
i++;
after the above two statements , I printed the vector and I got the output 1 3 5 whereas it should be 1 3 6 as I incremented the reference.
but when i do (v.back())++ and then print the values of the vector I get the result
1 3 6
I don't understand the difference in output , according to me it should be same. Please correct me if i am wrong.