Explain public derivation, C/C++ Programming

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.


                class base


                  private :

                                                int number;


                class derived : public base


                  public :

                                                void f()


++number;     // Private base member not




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.



Posted Date: 6/28/2013 5:17:02 AM | Location : United States

Related Discussions:- Explain public derivation, Assignment Help, Ask Question on Explain public derivation, Get Answer, Expert's Help, Explain public derivation Discussions

Write discussion on Explain public derivation
Your posts are moderated
Related Questions
Call by reference: Arguments to a function can be passed in two way; one by call by value and other by call by reference.  Call by value is passed either through a constant

write a program for convert numbers upto 9 to alphabet?Eg.now enter the inputis 666 means output is "0" lphabet

write a c++ program to accept 3 numbers and find the largest of 3 numbers

#questiowrite a program to calculate e^x

You must write a program that can both decrypt and encrypt a single word that is entered by the user. The initial choice of encryption and decryption is left up to the user. Addi

Linear search in array - C program: Write a program in c to define a linear search in array. void main()                 {                 clrscr();

Explain about the Constants in c language? The Constants in C refer to fixed values that don't change during the execution of a program. C has four fundamental types of constan

program of area under integration

I really have a hard time analyzing how to write a code in C. It''s all bout Time Departure and we must used a 24 hour clock. Can u help me?