请看一下这个简单的程序:
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> a;
std::cout << "vector size " << a.size() << std::endl;
int b = -1;
if (b < a.size())
std::cout << "Less";
else
std::cout << "Greater";
return 0;
Run Code Online (Sandbox Code Playgroud)
}
尽管很明显-1小于0,但它仍输出“ Greater”,这让我感到困惑size。谁能解释一下?