Quick notes to C programmers:
- instead of macros use
- - const or enum to de ne constants
- - inline to prevent function call overload
- - template to declare families of type and families of functions
- use new/delete instead of free/malloc (use delete[] for arrays)
- don't use void* and pointer arithmetic
- an explicit type conversion reveals an error of conception.
- avoid to use C style tables, use vectors instead.
- don't recode what is already available in the C++ standard library.
- variables can be declared anywhere: initialization can be done when variable is required.
- whenever a pointer cannot be zero, use a reference.
- when using derived class, destructors should be virtual.
0 comments:
Post a Comment