OOP CONCEPTS – A BRIEF INTRODUCTION

OOP CONCEPTS IN C++

5. INHERITANCE

As the name suggests.. Inheritance is the adequacy of one class of things to inherit properties or capabilities from another class. Generally, Inheritance is the process of formation of a new class from an existing class. The existing class is Base class and the new class is Derived class. Furthermore, we can say that..

We can define Inheritance as the process by which one object can obtain the properties of another object. Inheritance is important because it supports the concept of classification.

Certainly, Inheritance supports reusability of code. It allows the addition of additional features to an existing class without modifying it. One can derive a new class (sub-class) from an existing one and add new features to it.

Furthermore, Inheritance is transitive in nature. That means, if class B inherits properties of another class A.. Then all subclasses of B will automatically inherit the properties of A.

Following are the examples of Inheritance in a general layman’s Language..

  • For instance, the class “car” inherits some of its properties from the class “automobiles“.. Which inherit some of its properties from another class “vehicles“.
  • Furthermore, a red delicious apple is part of the classification “apple“.. Which in turn is part of the class “fruit“.. Which is under the larger class “food“.

Certainly.. The Inheritance mechanism makes it possible for one object to be a specific instance of a more general case. Also, Inheritance isone of the most important aspects​ of OOP.

6. POLYMORPHISM

Generally, Polymorphism is the capability for a message or data to be processing in more than one form. Polymorphism is a property by which the same message can be sent to objects of several different classes.. Furthermore, we can say that..

We can define Polymorphism as the adequacy to use an operator and function in different ways. In other words, giving different meaning to the operators or functions is Polymorphism. In simple terms, polymorphism is the attribute that allows one interface to control access to a general class of actions.

One can characterize the term Polymorphism by the phrase “one interface, multiple methods“. Polymorphism helps in reducing the complexity. How! By allowing the same interface to be using to access a general class of actions.

Following are the examples of Polymorphism in a general layman’s Language..

  • A real-world example of Polymorphism is a thermostat. No matter what type of furnace your house has, the thermostat works the same way. In this case, the thermostat i.e. the interface is the same.. No matter what type of furnace i.e. the method you have.
  • Another, 6+9 results into 15 but ‘X‘ + ‘YZ‘ results into ‘XYZ‘. The same Operator symbol ‘+‘ is able to distinguish between the two operations depending upon the datatype it’s working on.. The operations are summation and concatenation.

 

7. MODULARITY

Modularity is the property of a system that decomposes into a set of cohesive and loosely couple modules. Certainly, Modularity supports re-usability and also minimizes duplication. Furthermore, it comes under one of the most important features of OOP.

Let us understand the concept of Modularity with a general example in layman’s Language..

  • You must have seen a complete music system. Now, let us assume that our program represents the music system. The music system comprises of speakers, cassette player, record player, CD player, tuner, etc. These parts are complete units in themselves, yet they are a sub-part of the music system. This is Modularity.

 

Thus, it was all about The OOP CONCEPTS – A BRIEF INTRODUCTION.. For more information regarding the previous C++ post.. Click on

OBJECT-ORIENTED PROGRAMMING – A GENERAL INTRODUCTION

 

Leave a comment

Your email address will not be published. Required fields are marked *

19 thoughts on “OOP CONCEPTS – A BRIEF INTRODUCTION”