C + + Public,protected,private

Source: Internet
Author: User
  1. The private member of the base class is not visible after it is inherited (highest priority)
  2. Public inheritance does not change base class member properties
  3. Protect inheritance (private inheritance) change a base class member to a protected member (Private member)

public.

Protected protected

Private privately owned

When modifying a class member

1. The role of protected and private is the same when no inheritance is involved

2. The role is the same as public when it comes to inheritance

When modifying the inheritance mode

1. Public inheritance class A:public B

Public inherits the public member of the parent class to the child class's public

Inherits the protected member of the parent class to the protected of the child class

The private member of the parent class inherits to the invisible location of the child class

2 Protection inheriting class a:protected B;

3 Private inheritance

C + + Public,protected,private

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.