c******f 发帖数: 2144 | 1 看到这样一段代码:
for(vector::size_type ix = 0;ix != ivec.size(); ++ix, --cnt)
ivec[ix] = cnt;
为什么不写
for(int ix = 0;ix != ivec.size(); ++ix, --cnt)
ivec[ix] = cnt; | s*********t 发帖数: 1663 | 2 就是int,解决兼容性吧
【在 c******f 的大作中提到】 : 看到这样一段代码: : for(vector::size_type ix = 0;ix != ivec.size(); ++ix, --cnt) : ivec[ix] = cnt; : 为什么不写 : for(int ix = 0;ix != ivec.size(); ++ix, --cnt) : ivec[ix] = cnt;
| l******t 发帖数: 12659 | 3 因为ivect.size()是unsigned的;
size_type:
Type defined by the string and vector classes that is capable of containing
the size of any string or vector, respectively. Library classes that define
size_type define it as an unsigned type. | y**i 发帖数: 1112 | 4 这个也可以用size_t吧,我一般都写size_t
containing
define
【在 l******t 的大作中提到】 : 因为ivect.size()是unsigned的; : size_type: : Type defined by the string and vector classes that is capable of containing : the size of any string or vector, respectively. Library classes that define : size_type define it as an unsigned type.
|
|