Data Structures using C PlusPlus: Chapter 2: Inheritance and Polymorphism

Base Classes and Derived Classes

Question: 1. Explain the terms base class and derived class.

Base Classes and Derived Classes

• The class from which the data members and member functions are used by another class is called the base class.

• The class which uses the properties of base class and at the same time can add its own properties is called derived class.

• There are three types of access specifier or qualifier using which the members of the class are accessed by the other class ‒

1. Private

2. Public

3. Protected

• If a base class has private members then those members are not accessible to derived class.

• Protected members are public to derived classes but private to rest of the program.

• Public members are accessible to all.

• The derived class can inherit base class publicly or privately. The notation used for inheritance is :

For example ‒

class d1:public b1

class d2:private b2

• The first line indicates that there are two classes d1 and b1. It means "the derived class d1 inherits the base class b1 publicly".

• The second line indicates that there are two classes d2 and b2. It means "the derived class d2 inherits the base class b2 privately."

• The base class and derived class can generate their own objects. These objects differ from each other.

 

Review Question

1. Explain the terms base class and derived class.

 

Data Structures using C PlusPlus: Chapter 2: Inheritance and Polymorphism : Tag: Data Structure, C++, C Programing : - Base Classes and Derived Classes


Data Structures using C PlusPlus: Chapter 2: Inheritance and Polymorphism



Under Subject


Data Structures using CPlusPlus

CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation



Related Subjects


English Essentials II

EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation



Linear Algebra

MA25C02 2nd Semester | 2025 Regulation


Electron Devices

EC25C01 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Data Structures using CPlusPlus

CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Circuits and Network Analysis

EC25C02 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Re-Engineering for Innovation

ME25C05 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Engineering Drawing - Laboratory

ME25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Data Structures using CPlusPlus - Laboratory

CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Devices and Circuits Laboratory

EC25C03 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation