I'm trying to compare the following two quantities: an integer 'i' and the size of a vector v.
#include <vector>
#include <iostream>
using namespace std;
int main()
{
vector <int> v(26,0);
int i = -1;
cout << i << " " << v.size() << endl;
if (i < v.size()) cout << "a1" << endl;
else cout << "b1" << endl;
if (-1 < 26) cout << "a2" << endl;
else cout << "b2" << endl;
return 0;
}
When I run the following code, the output that I get is: -1 26 b1 a2
whereas I expect it to give: -1 26 a1 a2
Why is this happening?