C++ OOPs Concepts

tutorial and example
tutorial and example

C++ Object Oriented Programming Concepts

C++ uses the concept of object oriented programming. The Object Oriented Programming has some prominent features:

  1. Object
  2. Class
  3. Data abstraction
  4. Encapsulation
  5. Polymorphism
  6. Inheritance
  7. Message passing


Object is the basic unit of object oriented programming. It is a real time entity. It can represent any item that the program has to handle.

Declaration Syntax:


Here Fruit is class and mango is object.


Class is a user defined data type, which holds data members and member functions. Data members and member functions can be accessed by creating an instance (object) of the class. A class is created by using keyword class.

Declaration Syntax:


Data Abstraction

Abstraction refers to hiding the internal background details and reflecting only essential features. Abstraction represents the needed information in program without representing details.

For example, a base class data member and member function used in another class, but the other class does not know the implementation detail of data member and member function of base class.

Data Encapsulation

Data encapsulation refers to binding of data members and member functions into a single unit that is called class. The encapsulation prevents direct access of data. Data is only accessible through the member functions of the class.


Polymorphism means many forms. When a single task is performed in different ways is called polymorphism. Polymorphism provides implementation of same function name in multiple ways.


Inheritance is a feature in which one class inherits the property of another class. A class which inherits the property is called as derived class or sub class or child class and from which derived class inherits property is called as base class or patent class.

Message Passing

When a set of objects communicate with each other is called message passing. Message passing is done to sending and receiving information by objects. Following steps are followed in message passing:

  1. Creating classes having objects and their behavior,
  2. Creating objects from class definition,
  3. Establishing communication between objects.