Fundamentals of OOP
An OOPs Language has a few essential characteristics. Without these characteristics, we cannot call a programming language an OOPs language. These characteristics are also called the principles of Objective Oriented Programming. The characteristics are as follows:
Encapsulation
Data Abstraction
Polymorphism
Inheritance
Let's look at the characteristics in detail.
Encapsulation
Encapsulation is an information hiding mechanism. It combines both code and data together. Encapsulation is used to hide the values of an object inside a class. It prevents an unauthorized section of code from accessing the code directly. Before discussing encapsulation any further, let's look at a simple example. Look at the following code:
class AddNumbers { public: int addNumbersFunction(void) { return num1 + num2; } private: int num1 = 4; int num2 = 5 ; };
The AddNumbers
class has two sections-public
and private
...