One of the main objectives of Object Oriented Programming is to keep related things together. Encapsulation in C++ is about to bind the data and the functions that operate on them into a single entity called class. In traditional procedural programming like C, the data and functions are sort of independent. Code manageability can increase … Continue reading “Encapsulation in C++”
Abstraction in C++
Abstraction is a design concept of hiding data or implementation wherever possible and expose the essential parts only. Data hiding helps to prevent potential misuse and accidental change of data. Implementation hiding helps refactoring code by doing localized changes. In C++, the data and implementations are kept hidden as much as possible within the classes. … Continue reading “Abstraction in C++”
Polymorphism in C++
Polymorphism is about a same piece of code behaves differently in different situations. In C++, polymorphism is achieved by function overloading, operator overloading, and virtual function overriding. Same interface, function or operation, can be bound to different object types, hence, different behaviors. Binding can happen compile time or runtime. Base on that polymorphism is categorized … Continue reading “Polymorphism in C++”
Inheritance in C++
In Object Oriented Programming, inheritance is a mechanism of acquiring properties and behaviors in one class from another. In C++, one class can be derived from another class which is called base class. The derived class is often referred as a ‘child‘ class and the base one as ‘parent‘ class. It is like, the ‘child‘ … Continue reading “Inheritance in C++”
Friend Class in C++
The private and protected class members are not allowed to be accessed from outside the class. Only inherited or derived classes can access the protected members of its parent or base class. No other class or function can access them. But a friend class can access the private and protected members of a class where … Continue reading “Friend Class in C++”