Defaulted and Deleted Methods

C++11 provides more control over which methods are used. Suppose that you wish to use a defaulted function that, due to circumstances, isn’t created automatically. For example, if you provide a move constructor, then the default constructor, the copy constructor, and the copy assignment operator are not provided. In that case, you can use the keyword default to explicitly declare the defaulted versions of these methods:

class Someclass{public:   Someclass(Someclass &&);   Someclass() = default;      // use compiler-generated default constructor   Someclass(const Someclass &) = default;   Someclass & operator=(const Someclass &) = default;...};

The compiler provides the same constructor that it would have provided ...

Get C++ Primer Plus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.