Check out example codes for "access last element in vector in c++". It will help you in understanding the concepts better.

Code Example 1

vector<int> v;
cout << v[v.size() - 1];
cout << *(v.end() - 1);
cout << *v.rbegin();
// all three of them work

Learn ReactJs, React Native from akashmittal.com