Item 5: Know What Functions C++ Silently Writes and Calls

The 4 bread-and-butter functions: default constructor, copy constructor, copy assignment operator, and destructor.

  • Default constructor is generated if no constructor is declared.
  • Copy constructor and copy assignment operator are generated when it makes sense/unambiguous (e.g., no reference-typed member and no const member).
  • Destructor is generated (and declared virtual if needed) if no destructor is declared.
Creative Commons License
This blog by Che-Liang Chiou is licensed under a Creative Commons Attribution 4.0 International License.