Orange and Violet Illustration Class Syllabus Education Presentation

1 of
Published on Video
Go to video
Download PDF version
Download PDF version
Embed video
Share video
Ask about this video

Page 1 (0s)

INHERITANCE. Professor MANIKANDAN SIR. VELLORE INSTITUTE OF TECHNOLOGY, BHOPAL.

Page 2 (9s)

SHIVANI ARORA 21BHI10014. SRISHTI GAUTAM 21BHI10034.

Page 3 (18s)

The Mechanism of deriving a new class from an old one is called inheritance (or derivation). The old class is referred to as the base class and the new one is called the derived class or subclass. Inheritance is the capability of one class to inherit properties from another class. The most important advantage of inheritance is code reusability..

Page 4 (40s)

One major 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 5 (56s)

A class can be derived from more than one classes, which means it can inherit data and functions from multiple base classes. To define a derived class, we use a class derivation list to specify the base class(es). A class derivation list names one or more base classes and has the form: class derived-class: access-specifier base-class Where access-specifier is one of public, protected, or private, and base-class is the name of a previously defined class. If the access- specifier is not used, then it is private by default..

Page 6 (1m 40s)

Derived Class Base Class Feature A Feature A Feature B Feature B Feature C Feature C Feature D Accessible By the Derived Class Defined in Derived Clas.

Page 8 (2m 41s)

Single 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. This makes the code much more elegant and less repetitive. Inheritance is one of the key features of object-oriented programming. If the class hierarchy contains only two classes one is a base class and another is derived class then this form of class hierarchy is known as single Inheritance..

Page 9 (3m 10s)

Class A Class B derived from one base class A Class B Class C derived from derived dass B Class C.

Page 10 (3m 32s)

MULTIPLE INHERITANCE INHERITANCE -. Multiple Inheritance is the concept of Inheritance in C++ that allows a child class to inherit properties or behavior from multiple base classes. Therefore, we can say it is the process that enables a derived class to acquire member functions, properties, characteristics from more than one base class. In the diagram, there are two-parent classes: Base Class 1 and Base Class 2, whereas there is only one Child Class. The Child Class acquires all features from both Base class 1 and Base class 2. Therefore, we termed the type of Inheritance as Multiple Inheritance..

Page 11 (4m 8s)

Hybrid Inheritance Base Class Derived Class I Derived Class 2 Derived Class 3.

Page 12 (5m 18s)

Class B Class A —4 Class C Class D. When several classes are derived from a common base class it is called hierarchical inheritance. In C++ hierarchical inheritance, the feature of the base class is inherited onto more than one sub-class. For example, a car is a common class from which Audi, Ferrari, Maruti, etc can be derived. As shown in diagram, in C++ hierarchical inheritance all the derived classes have common base class. The base class includes all the features that are common to derived classes..

Page 13 (6m 23s)

Private Inheritance: It is the inheritance facilitated by private visibility mode. In private inheritance, the protected and public members of the base class become private members of the derived class. Public Inheritance: It is the inheritance facilitated by public visibility mode. In public inheritance, the protected members of the base class become protected members of the derived class and public members of the base class become public members of a derived class. Protected Inheritance: It is the inheritance facilitated by protected visibility mode In protected inheritance ,the protected and public members of base class become protected members of the derived class..

Page 14 (7m 7s)

EXAMPLE.

Page 15 (7m 50s)

Virtual keyword determines if a member function of a class can be over-ridden in its derived classes. The non-virtual member functions are resolved at compiling time and it’s called static binding. However, the c++ virtual member functions are resolved during runtime and it's called as dynamic binding..

Page 16 (8m 16s)

Suppose you have two derived classes B and C that have a common base class A, and you also have another class D that inherits from B and C. You can declare the base class A as virtual to ensure that B and C share the same subobject of A..

Page 17 (8m 34s)

Sometimes we need to repeat code or we need repeat the whole class properties. So it helps in various ways. 1.) It saves memory space. 2.) It saves time. 3.) It will remove frustration. 4.) It Increases reliability of the code. 5.) It saves the developing and testing efforts..