c++ - Doesn't the length of the array get validated at run time at VC++? -
when run program 5th element array has size 4 junk value instead of array out of bound exception. doesn't length of array validated @ run time @ vc++?
c++ has arrays bound checking, not using []
. std::array<t, n>::at(i)
check 0 <= < n
, , throw std::out_of_range
exception.
std::vector<t>
variable-length equivalent of array, , offers same at()
method. of course uses current vector length, not hardcoded n
.
Comments
Post a Comment