Why won't this work:

1
2
3
4
5
6
7
8
9
10
bool func()
{
    bool rv;
    return rv;   
}
int main()
{
    cout << func() ? "" : "Good" << "bye World!\n" << endl;
    return func();
}
closed account (zb0S216C)
It should. The only warnings I see is the implicit cast from bool to int, and the uninitialised rv object.

Is this another joke, wtf?

Wazzak
No. I just thought if I were gonna be couting 2 diff lines that only differ from each other bye like 2 characters, why not just append those 2 characters to the base string all in the same line.


btw I got it to compile as:
 
    cout << (func() ? "" : "Good") << "bye  world!\n" << endl;
closed account (zb0S216C)
Do you know why it compiles with those parentheses? If not, it's because << has a high precedence over ?:.

Wazzak
Last edited on
Topic archived. No new replies allowed.