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

Tree, Write algorithm and program for the conversion of a Tree to a Binary ...

Write algorithm and program for the conversion of a Tree to a Binary Tree

Arrays within a class, A r r a y s w i t h i n a c l a s s:...

A r r a y s w i t h i n a c l a s s: I t i s j u s t d ecl a r i n g o r c on s t ru c ti n g a d e r i v e d t

Develop stocastic expert advisor, Project Description: Need to develop a...

Project Description: Need to develop an expert advisor base on sthocastic oscilator with my own setting.. Very basic touch line OB/OS only but on my setting n condition Skill

What are the debugging methods you employ while came across , What are the ...

What are the debugging methods you employ while came across a problem? A: Debugging with tools such as: 1.      DBG, GDB ,Forte, Visual Studio. 2.      Using tusc to trace

PLS URGENT HELP WITH C++, Pls i only need help with program 2. #include ...

Pls i only need help with program 2. #include #include using namespace std; int main() { int FilingStatus; cout cout cout cout cout cout

ASCII, A string S is said to be "Super ASCII", if it contains the character...

A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''a''-''z'') and the asci

What is difference between require_once () and require(), What is differenc...

What is difference between require_once (), require(), include()? require() includes and evaluates a specific file, if file isn't found then it shows a Fatal Error. require_

Explain formatted input output with file pointer, Explain Formatted Input O...

Explain Formatted Input Output with File Pointer? Likewise there are equivalents to the functions scanf and printf which write or read data to files. These are called fscanf a

Explain rules for constructing variable names in c language, Explain Rules ...

Explain Rules for constructing variable names? The Rules for constructing variable names : a) A variable name is any combination of alphabets, 0 to 9 digits and undersc

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