Raw pointers in application classes of C++ considered harmful

  • Authors:
  • Igor B. Smirnov

  • Affiliations:
  • Petersburg Nuclear Physics Institute

  • Venue:
  • ACM SIGPLAN Notices
  • Year:
  • 2007

Quantified Score

Hi-index 0.00

Visualization

Abstract

In order to achieve good reliability, clarity, scalability and re-usability of the application high-level programs written in C++ the raw pointers should not be used as class members (fields), because the raw pointers are too dangerous in this role and they do not represent meaningful relations between objects. Instead of raw pointers two smart pointers should be used. The first one describes exclusive unique ownership with synchronization of objects copying and deletion. The second one describes inclusive references to independent alien objects with invalidating the reference at the deletion of the addressed object. All power of object-oriented programming is preserved, but difficulties and errors are eliminated.