Tagged: public inheritance

Interested in learning C Programming? Click here...

Single Inheritance - Public Inheritance in Cpp 2

Single Inheritance – Public Inheritance in C++

Inheritance in which the derived class is derived from only one base class is called single inheritance. Let us consider a simple example to illustrate the single inheritance. Program given below shows a base class B and a derived class D. The class B contains one private data member, one public data member and three public member functions. The class D contains one private data member and two public member functions.

Given below is the output of the above program:

In the above program, following things require to be noted: The class D is a public derivation of...

Defining of Derived Classes in Cpp 0

Defining of Derived Classes in C++

How do we define a derived class in C++ A derived class is defined by specifying it relationship with the base class in addition to its own details. The general form of defining a derived class is:

where, class is the required keyword, derived-class-name is the name given to the derived class, base-class-name is the name given to the base class, : (colon) indicates that the derived-class-name is derived from the base-class-name, visibility-mode is optional and, if present, may be either private or public. The default visibility-mode is private. Visibility mode specifies whether the features of the base class...