Final presentation programming

22

Transcript of Final presentation programming

Page 1: Final presentation programming
Page 2: Final presentation programming
Page 3: Final presentation programming
Page 4: Final presentation programming
Page 5: Final presentation programming
Page 6: Final presentation programming

Need for inheritance:

one basic reason behind this is the capability to express the inheritance relationship.

Another reason is the idea of reusability

one reason is transitive nature of inheritance

Page 7: Final presentation programming

Advantages of inheritance:some time we need to repeat the code or we need to repeat the whole class properties. So it helps in various ways

it saves memory spaceit saves time

it will remove frustrationit increase reliability of the code

it saves the developing and testing efforts

Page 8: Final presentation programming

Why we use inheritance?

To increase the reusability of the code and to make future usable for another classes.

we use the concept of inheritance

Page 9: Final presentation programming

How inheritance can be achieved?

In the inheritance there will be a parent child relationship. There is

a class called in which all the properties are defined and

generally, it is refered as a base class. There is also another class in which is derived from the existing one are known as a derived class.

Page 10: Final presentation programming

Inheritance Access SpecifiersPublic Inheritance

This inheritance mode is used mostly. In this the protected member

of Base class becomes protected members of Derived class and public

becomes public.

class B : public Aclass C : public B

Page 11: Final presentation programming

Inheritance Access SpecifiersProtected Inheritance

In protected mode, the public and protected members of Base class becomes protected members of

Derived class.

class B : protected Aclass C : protected B

Page 12: Final presentation programming

Inheritance Access Specifiers

Private InheritanceIn private mode the public and

protected members of Base class become private members of Derived

class.

class B : private Aclass C : private B

Page 13: Final presentation programming

Types of inheritanceThere are different types of

inheritance

single inheritanceMultiple inheritance

Hierarchical inheritancemultilevel inheritance

hybrid inheritance

Page 14: Final presentation programming

Single inheritanceSingle inheritance enables a

derived class to inherit properties and behavior from a single parent class. It allows a

derived class to inherit the properties and behavior of a

base class, thus enabling code reusability as well as adding new

features to the existing code.

Page 15: Final presentation programming

syntaxclass A

{--------------

};

class D : access specifier A{

--------------

};

Page 16: Final presentation programming
Page 17: Final presentation programming

Derived classIn Inheritance you create new

classes from existing class. Any new class that you create from an

existing class is called derived class.

Base classexisting class is called base class.

Page 18: Final presentation programming

SOURCE CODE

Page 19: Final presentation programming
Page 20: Final presentation programming
Page 21: Final presentation programming

OUTPUT:POSITION=0POSITION=1POSITION=0

Page 22: Final presentation programming