C++ fully supports object-oriented programming which includes the following:
Encapsulation is the property of being a self-contained unit. With encapsulation we can accomplish data hiding. Data hiding is the highly valued characteristic that an object can be used without the user knowing or caring how it works internally. C++ supports the properties of encapsulation through the creation of user-defined types, called classes.
Inheritance allows for the extension of an existing type. The new subclass derives from an existing type and is sometimes called a derived type.
Polymorphism is…