Hidden Features of C++? [closed]

Most C++ programmers are familiar with the ternary operator:

x = (y < 0) ? 10 : 20;

However, they don't realize that it can be used as an lvalue:

(a == 0 ? a : b) = 1;

which is shorthand for

if (a == 0)
    a = 1;
else
    b = 1;

Use with caution :-)


You can put URIs into C++ source without error. For example:

void foo() {
    http://stackoverflow.com/
    int bar = 4;

    ...
}