In the C++ Primer book, Chapter (3), there is the following for-loop that resets the elements in the vector to zero.
for (vector<int>::size_type ix = 0; ix ! = ivec.size(); ++ix)
ivec[ix] = 0;
Why is it using vector<int>::size_type ix = 0? Cannot we say int ix = 0? What is the benefit of using the first form on the the second?
Thanks.
The C++ Standard says,
Then it adds,
So most likely,
size_typeis a typedef ofsize_t.And the Standard really defines it as,
So the most important points to be noted are :
size_typeisunsignedintegral, whileintis not necessarilyunsigned. :-)