Check out example codes for "cpp get last element of vector". It will help you in understanding the concepts better.

Code Example 1

vector<int> vec;
vec.push_back(0);
vec.push_back(1);
int last_element = vec.back();
int also_last_element = vec[vec.size() - 1];

Learn ReactJs, React Native from akashmittal.com