Clause 6: If you don't want to use the compiler auto-generated function, it is expressly denied (explicity disallow the using of compiler-generated functions you does not want)

Source: Internet
Author: User

Class uncopyable{

Protected

Uncopyable () {}; Allow derived object construction and destruction

~uncopyable () {};

Private

Uncopyable (const uncopyalbe&); But stop copying.

uncopyable& operator= (const uncopyalbe&);

};

Class Homeforsale:private uncopyable{//class no longer declares

....//copy constructor or

}; Copy assignment operator

Generally either the client, member function, friend function tries to invoke the Copy Homeforsale object. This kind of writing will be categorically rejected.

Note:

In order to dismiss the function that the compiler automatically (secretly) provides, the corresponding member function can be declared private and not implemented, and the base class using Uncopyable is the same.

Clause 6: If you don't want to use the compiler auto-generated function, it is expressly denied (explicity disallow the using of compiler-generated functions you does not want)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.