#include <bits/stdc++.h>
using namespace std;
int main()
{
int a;
char b;
a = 66000;
b = 'C';
if (b == a)
std::cout << "1";
else
std::cout << "2";
}
The output of the above function is
2
What I don't understand is:
- How can C++ compare two different datatypes? I searched on google, I didn't find a satisfying answer.
- Is this a compiler issue or something I failed to read?
- Are
b == a
anda == b
the same comparison? Does order matter?
When a
's value is 67, the above program gives "1" as output.