I read the code written in C ++ as follows:
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int iarr[] = {30, 12, 55, 31, 98, 11, 41, 80, 66, 21}; vector<int> ivector(iarr, iarr + 10); }
in the above code, I pass iarr and iarr+10 to ivector(iarr, iarr + 10) to create a new vector, is this the right way to build a vector ? I checked the STL document, it doesnβt mention there, is this allowed?
and also the iarr array contains 10 elements, should I use an ivector(iarr, iarr+9) ?
c ++ arrays vector
user707549
source share