EC notes, Part Two: 6. If you do not want to use a function generated by the compiler by default, you should explicitly deny

Source: Internet
Author: User

6.If you do not want to use a function generated by the compiler by default, you should explicitly deny

1. Sometimes you do not want the object to be copied and assigned, then the copy constructor and the assignment operator are placed in thePrivate:, but do these two functions need to be implemented? Assuming the implementation, then your class member methods andfriendfunctions (classes) can still use these methods, the best way is toPrivate:do not define them, so that when the member method orfriend:When a function (class) attempts to invoke these methods, a link error is reported because the method is not implemented. (This is how to prevent copying in iostream )

2. Available in multiple inheritanceprotected:Control

Summarize:

EC notes, Part Two: 6. If you do not want to use a function generated by the compiler by default, you should explicitly deny

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.