Max length for an array in C++
There are two limits, both not enforced by C++ but rather by the hardware.
The first limit (should never be reached) is set by the restrictions of the size type used to describe an index in the array (and the size thereof). It is given by the maximum value the system's
std::size_t
can take. This data type should always be the largest integer type of a system.The other limit is a physical memory limit. The larger your objects in the array are, the sooner this limit is reached because memory is full.
1.e. on 32 bit OS : It is 32 bit long.
And on 64 bit OS : It is 64 bit long.
Comments
Post a Comment