Professional Documents
Culture Documents
Inheritance PDF
Inheritance PDF
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
By Hardeep Singh
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
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
By Hardeep Singh