No naked pointers
- Keep them inside functions and classes
- Keep arrays out of interfaces (prefer containers)
- Pointers are implementation-level artifacts
- A pointer in a function should not represent ownership
- Always consider std::unique_ptr and sometimes std::shared_ptr
No naked new or delete
- They belong in implementations and as arguments to resource handles
Return objects “by-value” (using move rather than copy)
- Don’t fiddle with pointer, references, or reference arguments for
piątek, 2 sierpnia 2013
C++ programming style
Subskrybuj:
Komentarze do posta (Atom)
Brak komentarzy:
Prześlij komentarz