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

OOPS

OOPS activities

Uploaded by

surendragos27
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 views10 pages

OOPS

OOPS activities

Uploaded by

surendragos27
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/ 10

INETRNAL TEST:-03

Topic:- Inheritance in object- oriented Programming

Name:- Surendra Nath Goswami


Course:- BCA(Normal)
Group:- 3C
Roll No:- 202310101310169
Subject:- Object Oriented Programming Using C++
Submitted To:- Mr. Shobhit
Inheritance in
Object-Oriented
Programming (OOP)
Inheritance is a fundamental concept in object-oriented programming
that allows classes to inherit properties and methods from parent
classes. This promotes code reuse and creates a hierarchical structure of
objects.
Definition of Inheritance
1 Code Reuse 2 Hierarchical
Relationships
Inheritance enables sharing
common code across Subclasses (child classes)
related classes, reducing inherit attributes and
duplication and improving behaviors from their
maintainability. superclasses (parent
classes).

3 Specialized Functionality
Subclasses can add or override inherited functionality to
specialize the class for specific use cases.
Types of Inheritance
Single Inheritance Multilevel Inheritance Hierarchical Inheritance

A subclass inherits from a single A subclass inherits from a superclass, Multiple subclasses inherit from a
superclass. which itself inherits from another single superclass.
superclass.
Inheritance Syntax in Programming Languages
Java C++
class Subclass extends Superclass { ... } class Subclass : public Superclass { ... }

1 2 3

Python
class Subclass(Superclass): ...
Advantages of Inheritance
Code Reuse Polymorphism
Inheritance allows you to Subclasses can override or
reuse code from parent extend inherited methods,
classes, reducing development enabling polymorphic
time and effort. behavior.

Modularity Extensibility
Inheritance promotes a New functionality can be
modular design, making the added by creating subclasses,
codebase more organized and without modifying existing
maintainable. code.
Disadvantage of Inheritance
1 Tight Coupling 2 Complexity
Inheritance can lead to Deep inheritance
tight coupling between hierarchies can increase the
classes, making the complexity of the codebase,
codebase less flexible. making it harder to
understand and maintain.

3 Fragility
Changes in a parent class can unintentionally break functionality
in its subclasses.
Overriding and Method
Overriding
Overriding
Subclasses can override inherited methods to provide their
own implementation.

Dynamic Dispatch
The appropriate method implementation is determined at
runtime based on the object's type.

Polymorphism
Method overriding enables polymorphic behavior, where
objects of different classes can be treated as the same type.
Inheritance and Code Reusability

Code Reuse
Inheritance promotes code reuse by allowing subclasses to inherit and extend
functionality from parent classes.

Maintainability
Inheritance helps keep the codebase organized and maintainable by establishing a clear
hierarchy of related classes.

Collaboration
Inheritance enables developers to build upon each other's work, fostering collaboration
and productivity.
THANK YOU!

You might also like