C++ Object-Oriented Programming Concepts

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

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


An 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 an 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 the 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 the base class.

Data Encapsulation

Data encapsulation refers to the 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 an implementation of the 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 a derived class or subclass or child class and from which derived class inherits property is called as a base class or parent 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 the class definition,
  3. Establishing communication between objects.

Pin It on Pinterest

Share This