vector size - 1 when size is 0 in C++

后端 未结 5 2198
渐次进展
渐次进展 2020-11-28 16:48

The following code

#include 
#include 
using namespace std;
int main() {
    vector value;
    cout << value.         


        
5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 17:16

    vector::size() is of type size_t which is an unsigned type, and unsigned integers can't represent negative numbers.

提交回复
热议问题