I\'m reading some lecture notes of my C++ lecturer and he wrote the following:
- Use Indentation // OK
- Never rely on operator preced
My 2c:
Use Indentation
Obviously
Never rely on operator precedence - Always use parentheses
I wouldn't use words "never and "always", but in general I see this rule being useful. In some languages (Lisp, Smalltalk) this is a non-issue.
Always use a { } block - even for a single line
I never do that and never had a single problem, but I can see how it can be good for students, esp. if they studied Python before.
Const object on left side of comparison
Yoda conditions? No, please. It hurts readability. Just use the maximum warning level when you compile your code.
Use unsigned for variables that are >= 0
OK. Funny enough, I've heard Stroustrup disagree.
Set Pointer to NULL after deletion - Double delete protection
Bad advice! Never have a pointer which points to a deleted or non-existing object.