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

Define automatic storage classes - computer programming, Define Automatic s...

Define Automatic storage classes - computer programming? The Variables declared within function bodies are automatic by default and automatic variables are declared inside a fu

201 it, overload assignment opertor to assign the data of one object to ant...

overload assignment opertor to assign the data of one object to anthor

Programming and solving problems with a computer, One person who is special...

One person who is specialist at programming and solving problems with a computer Project Description: Potential computer, hardware, programming and software genius, I look

Write a program that calculates circumference and area, Write a program cal...

Write a program called A1Q3, that reads it the radius of a circle as an integer and prints the circle's diameter, circumference and area.  Use a constant value for pi.  Do all calc

Decode the code, c++ coding decode the letters from numbers

c++ coding decode the letters from numbers

Operators, write a program to accept ten numbers and display the total

write a program to accept ten numbers and display the total

Define variable declaration in c++, Variable Declaration This declarati...

Variable Declaration This declaration of variables in the C language is permitted only in the starting of their block, prior to executable program statements. In C++ declaratio

Explain bit-wise operators, Bit-wise Operators Some applications requir...

Bit-wise Operators Some applications require operations to be done on dissimilar bits of a byte separately. Bit-wise operators offer a facility to do just that. There are vario

Stack push pop, 2 flowcharts, pseudocode for each (at least 4 algorithms), ...

2 flowcharts, pseudocode for each (at least 4 algorithms), and code for either a stack or a queuestion..

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