NIOS Computer Science: Chapter 14 – Inheritance Extending Classes Part 4

Download PDF of This Page (Size: 226K)

Image of public visibility mode

Image of Public Visibility Mode

Image of public visibility mode

The Public Visibility Mode

The following example and figure illustrate the public derivation in classes.

class student

{

private:

int x;

void getdata ( );

{

public:

int y;

void putdata ( );

protected:

int z;

void check ( );

};

class marks : public student

{

private :

int a ;

void readdata ( );

public :

int b;

void writedata ( );

protected :

int c;

void checkvalue ( );

};

Image of The Public Visibility mode

Image of the Public Visibility Mode

Image of The Public Visibility mode

The public derivation does not change the access specifies for inherited members in the derived class. The private data of base class student cannot be inherited.