+ 4

why array always start with index number 0...????

6th Sep 2016, 2:16 AM
Amit
Amit - avatar
3 odpowiedzi
+ 2
Maybe to align indexes with unsigned int values?
6th Sep 2016, 8:48 AM
Zen
Zen - avatar
+ 2
because computers count from zero and always have. I think it's a throwback to the early scientific uses of computers. it's not really important other than that you remember it. so for example vector.size() returns the number of elements, but to access the last element, you would have to take away one from the size: vector[vector.size() - 1] will get the last element of the vector.
6th Dec 2016, 7:54 PM
Thomas Brewster
Thomas Brewster - avatar
- 10
if you continue learning you will know that you can start it as you wish =D
6th Sep 2016, 4:05 AM
Yassen Maged Youssef
Yassen Maged Youssef - avatar