Special member functions

1

In the C++ programming language, special member functions are functions which the compiler will automatically generate if they are used, but not declared explicitly by the programmer. The automatically generated special member functions are: In these cases the compiler generated versions of these functions perform a memberwise operation. For example, the compiler generated destructor will destroy each sub-object (base class or member) of the object. The compiler generated functions will be, non-virtual and the copy constructor and assignment operators will receive parameters (and not be of the alternative legal forms).

Example

The following example depicts two classes: Explicit for which all special member functions are explicitly declared and Implicit for which none are declared.

Signatures

Here are the signatures of the special member functions:

C++03

In C++03 before the introduction of move semantics (in C++11) the special member functions were:

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

View original