Vecor

here why we have used " v(myints,myints+5) " there are 5 elements in array so why we haven't used v(myints,myints+4)?? because for 5 elements we use indexes 0 to 4 in an array?

1
2
   int myints[] = {10,20,30,5,15};
  std::vector<int> v(myints,myints+5);
End iterator should point past last element of the array.
Like we would use 5 in for loop condition.
^ but there is < sign not a <= sign in array ?
is it the same in vector like std::vector<int> v(myints,myints+5);
like for(i=0;i<5;i++)
cin>>v[i];

Topic archived. No new replies allowed.