[cs23021] Question Regarding size_t
Mikhail Nesterenko
mikhail at cs.kent.edu
Fri Nov 19 11:09:14 EST 2010
>
> I was wondering if size_t could be used as a type outside of vectors.
>
size_t is defined to be the type to use for indexes for arrays,
strings and vectors. It ensures better source code portability between
32 and 64 bit architectures. Note that size_t is unsigned type (as we
discussed in class) meaning that it cannot be compared to or
implicitly convert integer (which is signed) and size_t. The compiler
would generate a warning if you try to do something like that
size_t s=55;
int i = s;
However, the idea is that you just should not use integers for
indexes so the need to compare size_t to integer never arises.
Thanks,
--
Mikhail
More information about the cs23021-2
mailing list