C++1x-2x Special Member Func Ons: Compiler Implicitly Declares

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

C++1x-2x Special Member Func ons

compiler implicitly declares


Default constructor Destructor Copy constructor Copy assignment Move constructor Move assignment

Nothing Defaulted Defaulted Defaulted Defaulted Defaulted Defaulted

Any constructor Not declared Defaulted Defaulted Defaulted Defaulted Defaulted

C++98
Default constructor User declared Defaulted Defaulted Defaulted Defaulted Defaulted
user declares

Destructor Defaulted User declared Defaulted Defaulted Not declared Not declared

Copy constructor Not declared Defaulted User declared Defaulted Not declared Not declared

Copy assignment Defaulted Defaulted Defaulted User declared Not declared Not declared

Move constructor Not declared Defaulted Deleted Deleted User declared Not declared

Move assignment Defaulted Defaulted Deleted Deleted Not declared User declared

C++98
Move only classes
Deprecated
after C++11
The behaviour of the compiler supplying those is deprecated (but not in pre C++11)

Rule of three: if a class defines any of the destructor, copy constructor or copy assignment operator then it should probably explicitly define all three

Deleted Although deleted, they s ll exist, so they can par cipate in overload resolu on

You might also like