assume we have an array
int arr[3];
In C++11 we can do
end(arr);
to get the boundry of arr.
and
sizeof(arr)/sizeof(arr[0])
can get the size of array.
Actually I'm from Java, and new to C++, it's intuitive to have sth. like arr.length
, but why don't C++ have this nice feature? It's quite weird to use an outside function to get the size of an array.(And end function is even added after C++11, before that things are more troublesome) I guess it has sth. to do with the implementation behind array, there must be some boundry marker, just like '\0' at the end of string. Then why not make one step further to get sth. like arr.length?