I am still learning the fundamentals of programming through C++ and was trying some applications on C++ operators, but it seems there are things about them that I still don't understand.
I tried writing the following line to test the possibility of using equal to (==) as a ternary operator:
cout << "(2+2 == 2*2 == pow(2, 2)) == " << (2+2 == 2*2 == pow(2, 2)) << endl;
The output was 0
So, I suspected that this might be because the return value of pow(2,2) is a double while that of the first two operands is an integer and thus I tried the following:
cout << "(2+2 == 2*2 == int(pow(2, 2))) == " << (2+2 == 2*2 == int(pow(2, 2))) << endl;
cout << "(double(2+2) == double(2*2) == pow(2, 2)) == " << (double(2+2) == double(2*2) == pow(2,2)) << "\n\n";
The output for both lines of code was also 0.
I have also tried the use of parentheses to reduce the number of operands but ended up with the same output.