阅读背景:

v.size() return size_t not int 返回无符号整型数

来源:互联网 

 

In the C++ STL, the vector size() function return size_t, which is unsigned int, not int. So imagine this, define an empty vector<int> v, and v.size() should be 0, and you have a for loop, and has an end condition is v.size() - 1, which is 4294967295 actually, not -1. This might cause problem when i = 0, which can enter the for loop, but actually was supposed not entering it.In the C++ STL, the vector size() function




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: