C + + public inheritance, protection inheritance, and private inheritance

Source: Internet
Author: User

The inheritance methods in C + + are:
Public, private, protected three (they directly affect the members of the derived class, and the rules that their objects access to the base class members).
(1) Public: Inheritance keeps the properties of the members in the base class intact, and the private members in the base class are hidden. members of derived classesYou can access only public/protected members in the base class, not private members;object of the derived classOnly public members in the base class can be accessed.
(2) Private (private inheritance): The member properties in the inheritance base class are changed to private, and the private members are hidden. members of derived classesYou can access only the public/protected members in the base class, but not the private members; object of the derived class You cannot access any of the members in the base class.   
(3) protected (Protective inheritance): Each member property in the inheritance base class is changed to protected, and the private member is hidden. members of derived classes can access only public/protected members in the base class, not private members; object of the derived class You cannot access any of the members in the base class.

C + + public inheritance, protection inheritance, and private inheritance

Related Article

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.