The main purpose of C++ is to introduce the OOPs concept in C programming language which is a powerful language.
OOP is a concept of using objects in programming. It is a paradigm that uses objects and classes that aim to implement real-world entities. The entities such as inheritance, abstraction, polymorphism, etc that are used in programming.
There are few main principles that form the foundation of Object-Oriented programming or you can say that they are the Characteristics of an Object-Oriented Programming language. They are:
Objects are real-world entities that have state and behavior. Example. bike, Lamp, pen, table, etc. An object is an instance of a class. It can be physical and logical.
A class is a user-defined blueprint or prototype for creating Objects. It is a logical entity. We can say that classes are categories, and objects are items within each of those categories. It holds the data members and member functions and these members of a class can be accessed and used by creating an instance of that class.
Inheritance is also one of the main concepts of OOP. Inheritance is one of the processes or mechanisms in OOP in which one class(sub-class) acquires the properties(data members) and functionalities(methods) of another class(parent-class).
This feature in C++ help to optimize the size of the code.
Super Class: The class whose properties and functionalities are inherited by the Subclass is known as the superclass(a parent class or a base class).
Sub Class: The class that inherits the property and behavior of the other class(Superclass) is known as a subclass( a derived class, extended class, or child class).
Data abstraction refers to the process of hiding the details but only displaying the relevant information to the world, which is hiding the implementation details and displaying only its functionalities.
Abstraction can be achieved in two ways.
- Abstraction class.
Encapsulation in C++ is defined as the wrapping up of data(variable) under a single unit. The use of Encapsulation is to make sure that implementation detail or we can say sensitive data is hidden from the users. Encapsulation is also known as data hiding
Polymorphism means having many forms, which means it is the way of performing some task in many ways. That means a single function or an operator functioning in many ways.
Function overloading and Function overriding are used in order to achieve Polymorphism. There is a Compile-time Polymorphism and Runtime Polymorphism.
We will learn about each of the above concept of OOP separately in details in the further tutorial.