Вы находитесь на странице: 1из 11

Inheritance

and Class
Hierarchy
Submitted By:
Manish Kumar
MCA 2019
INHERITANCE

• Derive quality and characteristics from parents or ancestors.


• Like you inherit features of your parents.
• one of the fundamental features of object-oriented programming
• The process of obtaining the data members and methods from one class
to another class is known as inheritance
• Show the relationship between two or more classes.
• Inheritance makes the code reusable

17-02-2020 2
BASE---->DRIVE

• The class whose properties are


inherited by other class is called
the Parent or Base or Super
class.
• And, the class which inherits
properties of other class is called
Child or Derived or Sub class

17-02-2020 3
ADVANTAGE

• Application development time is less


• Application take less memory.
• Application execution time is less.
• Redundancy (repetition) of the code is reduced or minimized

17-02-2020 4
BASIC SYNTAX--EXAMPLE
class base_class class Account {
{
public:float salary = 60000;
Properties.....
Methods....... };
}; class Programmer: public Account {
class drived_class : visibility_mode base_class public:float bonus = 5000;
{
Properties..... };
Methods....... void main() {
}; Programmer p1;
cout<<"Salary: "<<p1.salary<<end
17-02-2020 l; 5
INHERITANCE VISIBILITY
MODE
• Depending on Access modifier used while inheritance, the availability of class
members of Super class in the sub class changes.
1. Public Inheritance
• the protected member of super class becomes protected members of sub class and
public becomes public.
2. Private Inheritance
• the protected and public members of super class become private members of derived
class.
3. Protected Inheritance
• the public and protected members of Super class becomes protected members of Sub
class.

17-02-2020 6
INHERITANCE
VISIBILITY MODE

17-02-2020 7
TYPES OF INHERITANCE

17-02-2020 8
TYPES OF INHERITANCE

17-02-2020 9
CLASS HIERARCHIES

17-02-2020 10
THANK YOU

17-02-2020 11

Вам также может понравиться