I'm new to C++ and i try many things to understand how it works.
In this code i don't understand why my first value of vec.end() is ok and after the erase method my vec.end() is equal to my last element(5).
One explanation would be that vec.end() would point to ex vec[4] (5) but when I apply once again vec.erase(), vec.end () is still equal to 5.
I would be very grateful if someone could explain to me why this is happening.
#include <iostream>
#include <vector>
int main()
{
std :: vector<int> vec{1 , 2 , 3 , 4 , 5};
auto it = vec.begin();
std :: cout << *(vec.end()) << std :: endl;
std :: cout << vec.size() << std :: endl;
vec.erase(it);
std :: cout << *(vec.end()) << std :: endl;
std :: cout << vec.size() << std :: endl;
return 0;
}