相关疑难解决方法(0)

向量大小 - 在C++中大小为0时为1

以下代码

#include <vector>
#include <iostream>
using namespace std;
int main() {
    vector<int> value;
    cout << value.size() << endl;  // output 0
    cout << value.size() - 1 << endl;  // output 18446744073709551615
}
Run Code Online (Sandbox Code Playgroud)

为什么第二个输出不是-1?第二次cout会发生什么?

c++ size vector

2
推荐指数
1
解决办法
1207
查看次数

标签 统计

c++ ×1

size ×1

vector ×1