1 / 14

C Inheritance Tutorial | Introduction To Inheritance In C Programming

This presentation on the C Inheritance tutorial will help you learn about Inheritance in C and why we use inheritance in C . You will also understand modes of inheritance and different types of inheritance in C . You will get an introduction to inheritance in C programming with examples of the different types of inheritance.<br><br>Below topics are covered in this presentation:<br>1. What is inheritance?<br>2. Why do we use inheritance?<br>3. Modes of inheritance<br>4. Types of inheritance<br>5. Single inheritance<br>6. Multiple inheritances<br>7. Multilevel inheritance<br>8. Hierarchical inheritance<br>9. Hybrid inhe

Simplilearn
Télécharger la présentation

C Inheritance Tutorial | Introduction To Inheritance In C Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What’s in it for you ? What is Inheritance ? Why do we use inheritance in C++? Modes of inheritance Types of inheritance Single inheritance Multiple inheritance Multi-level inheritance Heirarchical inheritance Hybrid inheritance

  2. What is inheritance ? Inheritance can be defined as a process in which objects of child class acquires properties and characteristics from the parent class. In C++, OOPs concept inheritance is one of the most important feature. The class which inherits the properties is called the derived class, and the class whose properties or characteristics are inherited is called the base class. Inherited properties

  3. Click here to watch the video

  4. Why do we use inheritance ? Inheritance is used because it helps in removing data redundancy and increases the reusability of code. To understand it, let’s suppose there are two classes two wheeler and four wheeler both of the classes contains similar functions like color() , brand(), Mileage(). Four wheeler Two wheeler Color() Brand() Mileage() Color() Brand() Mileage()

  5. Why do we use inheritance ? Base class Class vehicle Color() Brand() Mileage() With Inheritance, we inherit both the classes from one base class, i.e. class vehicle.. Now we have to write functions only once as both the classes are now inherited from the base class. Four wheeler Two wheeler Color() Brand() Mileage() Color() Brand() Mileage()

  6. Modes of inheritance There are three modes of inheritance i.e Public, protected and private. Public mode: In this mode of inheritance the public members of the base class remain public in the derived class, and same goes for protected members. Protected mode: In this mode the public and protected members of the base class will become protected in the derived class. Private mode: In Private mode protected and public members of class will become private in the derived class.

  7. Types of inheritance • There are various types of inheritance in C++ : • Single inheritance • Multiple inheritance • Multi-level inheritance • Heirarchical inheritance • Hybrid inheritance

  8. Single inheritance Class Base_class In this type of inheritance, there is a single derived class from a single base class. Syntax: Class derived_class : access_modifierBase_class { //body }; Class derived_class

  9. Multiple inheritance Class Base_class1 Class Base_class2 In this type of inheritance, the derived class is inherited from more than one base class. Syntax: Class derived_class : access_modifierBase_class1 , access_modifierBase_class2 { //body }; Class derived_class

  10. Multi-level inheritance In Multi-level inheritance, the derived class is inherited from another derived class. Syntax: Class Base_class2 : access_modifierBase_class1 { //body }; Class derived_class: access_modifierBase_class2 { //body }; Class Base_class2 Class Base_class1 Class derived_class

  11. Heirarchical inheritance If more than one class is inherited from the base class then it is known as hierarchical inheritance. Syntax: Class derived_class1: access_modifierBase_class { //body }; Class derived_class2: access_modifierBase_class { //body }; Class derived_class3: access_modifierBase_class { //body }; Class Base_class Class derived3 Class derived1 Class derived2

  12. Hybrid inheritance Hybrid inheritance is implemented by combining more than one type of inheritance. It can be said as the combination of both multilevel and hierarchical inheritance. Class derived_class1 Class Base_class1 Class derived_class3 Class derived_class2

More Related