Object Oriented Programming(OOPS) in C++

Object Oriented Programming(OOPS) in C++

3 min read

There are two common programming methods:

  1. Procedural programming
  2. Object-oriented programming (OOP)

Procedural Programming

A program in a procedural language is a list of instructions, which are followed step by step.
In a procedural paradigm, the emphasis is on doing things. Also, in this, data types are used and worked upon by many functions. Any change made by function to a data type is reflected in all locations of function.
Lastly, it does not model the real world very well.

Object-Oriented Programming

  • C++is known as the extension of C because it contains the features of OOPS.
  • OOPS stands for Object-OrientedProgramming. It offers a real-world relationship.
  • It is a programming paradigm based on the concept of OBJECTS that contains data and methods.
  • It offers a new and powerful way to cope up with bugfree , easy to maintain and reusable programs.

The difference between Object-Oriented Programming(OOPS) and procedural programming are :

Difference between OOPS and Procedural Programming
Image developed by Priya Chawla

The basic concept of OOPS

Before the discussion of the basic concepts, we should know what does an object and a class mean.

Object

An object is an identifiable piece of code with some characteristics and behavior. Just look around you, the book you are reading, the pen.
You are writing with are all objects.

Classes

A class is a group of objects that share common properties and relationships. For example, fruits is a class whereas orange, litchi are the Objects respectively.

Features of Object-Oriented Programming(OOPS)

Data Abstraction:

It is defined as the act of representing essential features without including background details. For example: While driving a car, you are only in contact of its outer features like gear handling, accelerator, brakes, etc. You don’t have to worry about its internal connections like wiring, motor working i.e, they are hidden/abstracted from you.

Encapsulation:

It is the most fundamental concept in oops. The wrapping up of data and operations/functions (that operates on data) into a single unit (called class) is known as encapsulation. A class describes encapsulation.

Abstraction and Encapsulation are complementary concepts. Encapsulation is a way to implement data abstraction. You will understand more about it in classes

Modularity:

Modularity is the property of a syste that has been decomposed into a set of cohesive and loosely coupled modules. It is required in a program because

  • It reduces program complexity to some degree.
  • It creates a number of well- defined, documented boundaries within the program.

Let us take the example of a computer system. The music system comprises speakers, monitors, printers, etc.Thus these are the modules for the System.

Inheritance:

It is defined as the capability of one class of things to inherit capabilities or properties from another class. As In the class car inherits some of its properties from class automobiles which inherits some properties from class vehicle.

Example On different OOPS Properties
Image Developed by Priya Chawla

Polymorphism:

It is defined as the ability for a message or data to be processed in more than one form.

ADVANTAGES OF OOPS

  • Re-use of code.
  • Ease of comprehension.
  • Ease of fabrication and maintenance.
  • Easy redesign and extension.

DISADVANTAGES OF OOPS

  • With OOPs, classes tend to be overly generalized.
  • The relations among classes become artificial at times.
  • The OOP program design is tricky.
  • To program with OOP, The programmer needs proper skills, thinking, etc.

Hope so, you would like my post, Please follow me on  my profile @priya123 to get latest post Developed by me.

Tags:
Choose your Reaction!
  • Have you ever thought about adding a little bit more than just your articles? I mean, what you say is valuable and everything. But think of if you added some great photos or videos to give your posts more, “pop”! Your content is excellent but with pics and clips, this site could certainly be one of the best in its niche. Terrific blog!

  • Comment Thanks Abila, for your advice. I will try to serve you better next time..

Leave a Comment