18 de mayo de 2009

The Beauty and the Ugly of C++ coding

This both snippets of code will do the same.
The first one is longer but more readable:

if (show) {
    p->Show();
}
else {
    p->Hide();
}

And the second one is more compact but is almost illegible I've to say:

(p->*(show ? &View::Show : &View::Hide))();