I have as basic a question as I think has ever been asked on this forum. I have searched through the conditional/ternary operator responses on this forum and still can't understand why I'm having the following problem. I am learning C++ from a book and have typed the following into my NetBeans 6.9 ide on mac snow leopard OS:
int x = 5;
float y = 5.5;
cout << (x > y) ? x : y;
when I compile this the response is: 0.
When I enter:
if (x > y)
cout << x;
else
cout << y;
I get what I am expecting which is: 5.5
Can anyone help me understand why I get 0 with the conditional operator?