Check out example codes for "c++ how to loop through a vector but not the last element". It will help you in understanding the concepts better.

Code Example 1

std::vector<int> vec{1,2,3};
for (int* it{vec.begin()} ; it != std::prev(vec.end()) ; it++)
  #Do something

Learn ReactJs, React Native from akashmittal.com