I am trying to understand how the ternary operator works in C++.
I expect to see the same output for both print statements, yet the second print statement outputs 49.
Why is this?
#include <iostream> using namespace std; int main() { int test = 0; cout << "First character " << '1' << endl; cout << "Second character " << (test ? 3 : '1') << endl; return 0; } Output:
First character 1
Second character 49