C/C++ trick with logical operators
Let me show a nice C/C++ trick I just found out:
Instead of writing:
if (function1())
function2();
you could write:
function1() && function2();
because the right side of the && operator is only evaluated (in this case: called), when function1() is true (returns a non-null value).
Subsequently, instead of:
if (!function1()) // or if (function1()==0) etc.
function2();
you could write:
function1() || function2();
Cool, eh?