Explain public derivation, C/C++ Programming

Assignment Help:

Public derivation

Public derivations are much more common than private derivations. In this situation:

  • The private members inherited from the base class are inaccessible to new members' functions in the derived class.
  • The public members inherited from the base class might be accessed by new members functions in the derived class and by instances of the derived class.

 e.g.

                class base

                 {

                  private :

                                                int number;

                 };

                class derived : public base

                 {

                  public :

                                                void f()

                                                 {

++number;     // Private base member not

                 accessible

                                                 }

                 };

The compiller error message is ' base :: number ' is not accessible in the function derived::f();

Here, only if the number is public then you can access it.

 

 


Related Discussions:- Explain public derivation

Can any constructor throw an exception?, Can any constructor throw an excep...

Can any constructor throw an exception? How to handle error while the constructor fails?

Car rental payment system, payment system, in c++ only..just use the printf...

payment system, in c++ only..just use the printf or scanf.please

Restart, how to create program in c that will system restart

how to create program in c that will system restart

Destruction of local object, Need assignment help What's the order that ...

Need assignment help What's the order that local objects are destructed?

Oops, how to create the programs in c++ knowledge

how to create the programs in c++ knowledge

Define internal static storage class - computer programming, Define Interna...

Define Internal static storage class - computer programming? The Internal static variables are those that declared inside a function. The scope of the internal static variables

Static optimality theorem, Question 1 Describe the following with respect ...

Question 1 Describe the following with respect to pointers in C language- Pointers and Arrays Usage of Pointers in functions Write programs in C to demonstrate the

Described overriding?, In order to override a method, a subclass of the cla...

In order to override a method, a subclass of the class which originally declared the method have to declare a method along with the same name, return type (or a subclass of that re

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd