OOPs Concepts

What is OOPs?

Object-oriented programming – uses objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, data hiding, polymorphism, etc in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of code can access this data except member function.

Concepts of OOPS in C++ programming

OOPS stands for “Object-Oriented Programming System” in C++ programming, Here we are discussing the concepts of OOPS (or main features of OOPS).

There are the following concepts of OOPS:

  • Classes
  • Objects
  • Inheritance
  • Data Encapsulation
  • Data Abstractions
  • Polymorphism

1) Class

Class is the template of an object. That logically encapsulates data members and member functions into a single unit. Classes are data types based on which objects are created.

2) Object

An object is a basic unit of OOPS. It has a unique name. An object represents a particular instance of a class. We can create more than one object of a class. The size of the class is size of total number of data members of the class.

3) Inheritance

Inheritance is the process of creating a new class from an existing class or base class. By using the concept of Inheritance, we can use implemented (existing) features of a class into another class).

The base class is also known as parent class or superclass. The new class that is formed is called a derived class. The derived class is also known as subclass or child class. Inheritance is basically used for reducing the overall code size of the program.

4) Data Encapsulation

Data encapsulation combines data members and member functions into a single unit that is called class. The advantage of encapsulation is that data cannot access directly. It is only accessible through the member functions of the class.

5) Data Abstraction

Data abstraction specifies hiding the implementation detail for simplicity. It increases the power of programming language by creating user defined data types.

6) Polymorphism

Polymorphism is a basic and important concept of OOPS. Polymorphism specifies the ability to assume several forms. It allows routines to use variables of different types at different times. In C++, an operator or function can be given different meanings or functions. Polymorphism refers to a single function or multi-functioning operator performing in different ways.