Search⌘ K

Request and Suppress Methods

Explore how to effectively use the default and delete keywords to request or suppress the compiler-generated special methods in C++. Understand their role in managing constructors, destructors, and assignment operators, enabling you to control object creation and behavior in your classes.

Special methods #

Since C++11, there has been a list of special methods that the compiler can generate implicitly if we have not defined them:

  • Default constructors and destructors.

  • Copy/move constructors and copy/move assignment operators.

  • new and delete operators for objects and C arrays of objects.

  • The default and delete ...