Download - Final presentation programming
![Page 1: Final presentation programming](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/1.jpg)
![Page 2: Final presentation programming](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/2.jpg)
![Page 3: Final presentation programming](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/3.jpg)
![Page 4: Final presentation programming](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/4.jpg)
![Page 5: Final presentation programming](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/5.jpg)
![Page 6: Final presentation programming](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/6.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/7.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/8.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/9.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/10.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/11.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/12.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/13.jpg)
Types of inheritanceThere are different types of
inheritance
single inheritanceMultiple inheritance
Hierarchical inheritancemultilevel inheritance
hybrid inheritance
![Page 14: Final presentation programming](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/14.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/15.jpg)
syntaxclass A
{--------------
};
class D : access specifier A{
--------------
};
![Page 16: Final presentation programming](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/16.jpg)
![Page 17: Final presentation programming](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/17.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/18.jpg)
SOURCE CODE
![Page 19: Final presentation programming](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/19.jpg)
![Page 20: Final presentation programming](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/20.jpg)
![Page 21: Final presentation programming](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/21.jpg)
OUTPUT:POSITION=0POSITION=1POSITION=0
![Page 22: Final presentation programming](https://reader035.vdocuments.us/reader035/viewer/2022062903/58ecb0051a28ab45438b45eb/html5/thumbnails/22.jpg)