piątek, 2 sierpnia 2013

C++ programming style

  1. 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
  2. No naked new or delete

    • They belong in implementations and as arguments to resource handles
  3. Return objects “by-value” (using move rather than copy)

    • Don’t fiddle with pointer, references, or reference arguments for

references:

Brak komentarzy:

Prześlij komentarz