0% found this document useful (0 votes)
106 views11 pages

Understanding Inheritance Basics

The document discusses inheritance in object-oriented programming. It defines inheritance as a mechanism that allows a class A to inherit properties from another class B. It describes different types of inheritance like single, multiple, hierarchical and multilevel inheritance. The major advantages of inheritance are reusability of code and reduced complexity. Inheritance also allows derived classes to access members of base classes depending on the access specifier used.

Uploaded by

Surendar Karnan
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)
106 views11 pages

Understanding Inheritance Basics

The document discusses inheritance in object-oriented programming. It defines inheritance as a mechanism that allows a class A to inherit properties from another class B. It describes different types of inheritance like single, multiple, hierarchical and multilevel inheritance. The major advantages of inheritance are reusability of code and reduced complexity. Inheritance also allows derived classes to access members of base classes depending on the access specifier used.

Uploaded by

Surendar Karnan
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

The mechanism of deriving a

new class from an old one is


called inheritance or derivation.

Definition of Inheritance:
Inheritance is the mechanism
which allows a class A to
inherit properties of a class B.

By Hardeep Singh

Single inheritance

Multiple inheritance
A

C
By Hardeep Singh

Hierachical Inheritance:
A
B

Multilevel Inheritance:
A
B
C
By Hardeep Singh

Hybrid Inheritance:
A

C
D

By Hardeep Singh

The major advantage is the reusability. Once


a base class is written and debugged,it need
not be touched again,but can be used to work
in different.
It also reduces the frustration in complex
programming.
Reusing exiting code saves time.

By Hardeep Singh

The larger the inheritance model gets, the


wider the mapped table table gets, in that
for every field in the entire inheritance
hiearchy, a column must exit in the mapped
table.

By Hardeep Singh

Public:
Exp: class A
{
Public:
Int x;
Private:
Int y;
};
Class B : public A
{
Private:
Int p;
}

By Hardeep Singh

Base class

Derived class visibility

Visibility

Public derivation

Private derivation

Protected

Private

Not inherited

Not inherited

Not inherited

Public

Public

Private

protected

protected

protected

private

Protected

By Hardeep Singh

Exp:class a
{
Private:
Int x;
Public:
Int y; };
Class B : private A
{
Int p; };
By Hardeep Singh

Exp:
Class A : protected B
{
Private : int X;
};

By Hardeep Singh

An abstract class is one that is not used to


create [Link] abstract class is used only
for base class.

By Hardeep Singh

You might also like