!-- Global site tag (gtag.js) - Google Analytics --> OOPs Concepts in c++ - programmingworld

Breaking

OOPs Concepts in c++


                  Basic OOPs Concepts In C++



  Concepts of oops:-


·       Inheritance

·       Polymorphism

·       Data Encapsulation

·       Data Abstraction

·       Modularity





Inheritance:-

Inheritance means, one class properties are used in drive class. It means, we can easily access base class using drive class.


Reason Why Inheritance Use:


    1.  One major reason behind this is the capability to express the inheritance relationship which makes it ensure the closeness with the real-world models.


    2.  Another reason is the idea of reusability. Inheritance allows the additional feature to an existing class without modifying it. One can derive a new class from an existing one and new feature to it.


    3. One reason is transitive nature.


Data Abstraction:-


It is the most important feature of OOP. Abstraction means, hiding the data. It means, we create an empty class and its class has nobody. To understand abstraction, let us take an example. You are driving a car. You only know the essential features to drive a car example, gear handling, steering handling, use of the clutch, accelerator, brakes etc. You just apply the brakes etc. What is happening inside is hidden from you. This is an abstraction. Take another example of ‘switchboard’. You only press those switches according to your requirement. You needn’t know. Again this is an abstraction, you know only the essential things to operate on switchboard without knowing the background details of a switchboard.


Data Encapsulation:-


Encapsulation means the wrapping up of data and operations /functions (that operate on the data) into a single unit (called class) is known as Encapsulation.

In Encapsulation, we wrapping data inside the class using Encapsulation.

The one only way to access the data is provided by the functions. These functions are called member functions in c++. The data cannot be accessed directly. If you want to read data in an object, you can call a member function in the object. It will read the data and return the value to the user. You can’t access the data directly. If data is hidden, so its safe from accidental alteration. Data and its functions are said to be encapsulation into a single entity.


Modularity:-


 It reduces its complexity of some degree.

A module is a separate unit in itself. It can be compiled separately though it has a connection with other modules. Modules work for the hand in order to achieve the program’s goal.


Polymorphism:-


Polymorphism is a feature of c++, in the polymorphism we create functions with same name but different arguments, which is performs different actions. Its means, functions with the same name, but different arguments and return type.


Class:


The Class is a collection of objects. It is a logical entity.


A class is a blueprint representing a group of objects which is shared common properties

Object:


The Object is an entity with some characteristics and behavior. An Object is an instance of a class. When an object is created/define memory is allocated to an object.


Advantages and Disadvantage of OOPs concepts in C++

Advantages of OOPs :


1.  Re-use of code: Encapsulation allows a class to be re-used in other applications. The availability of a consistent interface to object lessons code duplication and thereby improves code re-usability.


2.  Ease of comprehension: The classes can be set up to close the generic application concepts and processes. C++ OOPs codes are more near to real-world models than other programming methodologies codes.


3.  Ease of fabrication and maintenance:


4.  Easy redesign and extension:  some concepts facilitate easy redesign an extension.


Disadvantages of OOPs


1.  The OOPs programs are designed tricky.


2. OOP, classes tend to be overly generalized.


3.  Also one need to do proper planning and proper design for OPP programming.