devxlogo

How to Make a Private Member Public

How to Make a Private Member Public

You can make a privately inherited member public by specifying its access modifier in the derived class. For example:

 #include class base{   public:      int a;      int b;      base()      {        a=10;        b=20;      }      void show_a(void)      {       cout<


In the above example, the class named base is privately inherited into the class derived, making the variables a, b, and member functions show_a(), show_b() private, but making a declaration of a and show_a() in the public section of derived, making them public again.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist