I\'m reading some lecture notes of my C++ lecturer and he wrote the following:
- Use Indentation // OK
- Never rely on operator preced
It's very easy to accidentally change control-flow with comments if you do not use { and }. For example:
if (condition)
do_something();
else
do_something_else();
must_always_do_this();
If you comment out do_something_else() with a single line comment, you'll end up with this:
if (condition)
do_something();
else
//do_something_else();
must_always_do_this();
It compiles, but must_always_do_this() isn't always called.
We had this issue in our code base, where someone had gone in to disable some functionality very quickly before release. Fortunately we caught it in code review.