Check out example codes for "split vector in half cpp". It will help you in understanding the concepts better.

Code Example 1

std::vector<int> vec = {89, 15, 51, 27, 98};
std::size_t const half_size = vec.size() / 2;
std::vector<int> half1(vec.begin(), vec.begin() + half_size);
std::vector<int> half2(vec.begin() + half_size, vec.end());

Learn ReactJs, React Native from akashmittal.com