0% found this document useful (0 votes)
8 views3 pages

Inheritance Extending Classes Class12

Chapter 6 discusses inheritance in object-oriented programming, highlighting its role in creating derived classes from base classes and the benefits of code reusability. It outlines different forms of inheritance, including single, multiple, multilevel, hierarchical, and hybrid inheritance, as well as access control mechanisms for inherited members. The chapter concludes that inheritance is crucial for promoting reusability and logical organization of code.

Uploaded by

shinshan9954
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Inheritance Extending Classes Class12

Chapter 6 discusses inheritance in object-oriented programming, highlighting its role in creating derived classes from base classes and the benefits of code reusability. It outlines different forms of inheritance, including single, multiple, multilevel, hierarchical, and hybrid inheritance, as well as access control mechanisms for inherited members. The chapter concludes that inheritance is crucial for promoting reusability and logical organization of code.

Uploaded by

shinshan9954
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Class 12 Computer Science - Chapter 6 Notes

Inheritance: Extending Classes

Chapter 6: Inheritance - Extending Classes

6.1 Introduction

Inheritance is a powerful feature in object-oriented programming. It allows the creation of a new class (called

a derived class) from an existing class (called a base class). The derived class inherits the properties and

methods of the base class.

The most important advantage of inheritance is code reusability. It enables a tested and debugged program

to be reused in various programs without having to rewrite it. Already tested and reused code increases

program reliability and saves time, money, and effort.

6.2 Need for Inheritance

Inheritance reflects the real-world hierarchy. For example, "car" can be a base class, and specific car models

can be derived classes. The new derived class can use old data and add new properties.

6.3 Different Forms of Inheritance

- Single Inheritance

- Multiple Inheritance

- Multilevel Inheritance

- Hierarchical Inheritance

- Hybrid Inheritance

6.4 Derived and Base Classes


Class 12 Computer Science - Chapter 6 Notes
Inheritance: Extending Classes

A derived class is created using the syntax:

class derived_class_name : access_specifier base_class_name

// additional members

};

6.5 Inheritance Access Control

Access specifiers determine the visibility of inherited members:

- public: accessible outside class

- private: only within class

- protected: accessible within class and subclass

6.6 Multiple Inheritance Revisited

Multiple inheritance involves a class inheriting from more than one base class. This may lead to ambiguity,

which is resolved using scope resolution.

6.7 Multilevel Inheritance

In multilevel inheritance, a class is derived from a derived class. For example: class C inherits from class B

which inherits from class A.

6.8 Nesting of Classes

Classes can be defined inside other classes. This is known as nesting of classes, used in situations where

class definition is useful only within another class.


Class 12 Computer Science - Chapter 6 Notes
Inheritance: Extending Classes

Conclusion:

Inheritance is essential in OOP as it promotes reusability, better organization, and logical structuring of code.

You might also like