Public Inheritance Assignment Help

Assignment Help: >> Inheritance - Public Inheritance

Public Inheritance

The most important categories of access specifier are public. Within a public derivation

  • Every public member in the base class is public in the derived class
  • Every protected member in the base class is protected in the derived class
  • Every private member in the base class remains private in the base class

The common syntax of the public derivation is:

class base_class_name

{

......

......

};

class derived_class_name:public base_class_name

{

..................

..................

};

For instance, the following program segment demonstrates how to access every member of the base class through the derived class members:

Class baseA

{

private:

int x;

protected:

int y;

public:

};

int z;

class derivedD:public baseA

{

private:

int w;

};

A class derivedD is derived from the base class baseA and the access specifier is public. A data members of the derived class derivedD is

int x

int y;

int z;

int w;

The given table displays the access specifier of the data member of the base class in the derived class:

1756_public inheritanc.png

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