Object-Oriented Programming Features
Overview
Let’s look at some important object-oriented programming features in this post. In C++ programming language, everything revolves around the object of the class.
Features
The main object-oriented features are as follows:
- Classes
- Objects
- Inheritance
- Encapsulation
- Abstraction
- Overloading
Class
Class is basically a blueprint for an object. It declares and defines what data variables the object will have and what operations can be performed on the class’s object.
Objects
Objects are instances of classes and are used to interact with each other to create applications. Instance means the manifestation of the class. The object of the class on which we currently work. Objects have data members and member functions to perform the tasks.
Inheritance
Inheritance is a way to reuse written code again and again. The class which is inherited is called the base class and the class which inherits is called the derived class. So when a derived class inherits a base class, it can use all the functions which are defined in the base class, hence making code reusable.
Abstraction
Abstraction refers to showing only the essential features of the application and hiding the details. In C++, classes provide methods to the outside world to access and use the data variables, but the variables are hidden from direct access.
Encapsulation
It can also be called data binding. Encapsulation is all about binding the data variables and functions together in class.
Polymorphism
The polymorphism feature lets us create functions with the same name but with different arguments, which will perform differently as per the implementation.
Overloading
Overloading is a part of polymorphism. Where a function or operator is defined many times to perform different functions.