13.1.5. Using = default

Image

We can explicitly ask the compiler to generate the synthesized versions of the copy-control members by defining them as = default7.1.4, p. 264):

class Sales_data {public:    // copy control; use defaults    Sales_data() = default;    Sales_data(const Sales_data&) = default;    Sales_data& operator=(const Sales_data &);    ~Sales_data() = default;    // other members as before};Sales_data& Sales_data::operator=(const Sales_data&) = default;

When we specify = default on the declaration of the member inside the class body, the synthesized function is implicitly inline (just as is any other member function defined in the ...

Get C++ Primer, Fifth Edition 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.