0

What it indicates: v(input,input+7) in the code below? And why to use that in sort function too?

int input[] = {1,23,3, 14,8,5,12} ; vector<int>v(input,input+7); ...... sort(input,input+7)

22nd Aug 2018, 2:08 PM
Tincture
1 Respuesta
+ 1
Ayshi your first line is array and you might be aware that array name used alone denotes nothing but address of it's first element.. As pointer is address of something, we can say indirectly that array name is pointer.. array name +7 point to 7th element of array.. As in c++, pointer can be used in place of iterators... so, we can say that two pointers arrayname and arrayname +7 are two iterators passed to constructor of vector.. coming to line of sort function, it's again require two iterator to sort the container data... feel free to ask if it's not clear
22nd Aug 2018, 4:14 PM
Ketan Lalcheta
Ketan Lalcheta - avatar