The main advantage of C++ programming language over C is that it supports Object Oriented Programming. It includes classes and objects.
A class is used to specify the form of an object, whereas an object is a real-world entity.
If we take Dog as a class, then a Dog has some properties, like it has 4 legs and a tail, so these are actually the data members of the Dog class.
On the other hand, a dog performs some functions like it barks, so these are member functions of dog class.
Now, suppose a dog is named Joe, then it will have all the features of the dog class and perform the function of barking, thus here Joe is an object i.e. a real-world entity that has an existence while the class Dog has no real world existence.
C++ fully supports object-oriented programming, including the four pillars of object-oriented development −
1. Data Encapsulation – It is a OOPs concept that helps the user views only that data which is relevant for them. For Example: A capsule medicine.
2. Data Hiding – Data Hiding ensures the protection of sensitive data from unauthorized user access.
3. Inheritance – One of the most important concepts in object-oriented programming is that of inheritance. Inheritance allows us to define a class in terms of another class, which makes it easier to create and maintain an application.
The idea of inheritance implements the IS A relationship. For example, mammal IS-A animal, dog IS-A mammal hence dog IS-A animal as well.
4. Polymorphism – The word Polymorphism is made up of two words: Poly means many, and Morph means forms, it occurs when hierarchies of classes are related by inheritance.
We will read about all these concepts of OOPs in detail later on.