CPP introduced the features of OOPs Concept, i.e, CPP is an object-oriented programming language which uses classes and objects for computations. However, it is not considered to be truly object-oriented programming language.
Advantages of Object Oriented Programming Language:
- Development and maintenance of is easier than the procedural programming.
- Easy to solve the real world problems as it does not works on step by step instructions.
- Data are more secure due to its special feature of data hiding.
Principles of OOPs:
An object oriented programming is based on seven fundamental principles.
- Data Abstraction
Anything that has state and behavior can be termed as an Object, be it physical or logical. An Object is an entity mentioned in OOPs concept and is frequently found in CPP codes.
A collection of Objects is termed as Class in OOPs concept. Every class has its own unique and distinguishable attributes and methods.
Method is similar to a function. It is just a name given to a function associated with an object. That is, in OOPs concept function is termed as Method. In CPP, object of any type can have methods which is not necessarily unique to any class instance.
The property of acquiring all the properties and behaviors of the parent object by an object is termed as inheritance in OOPs. This is a unique feature in object oriented programming languages which facilitates reusability of the code of the parent class by the derived class.
OOPs is based on the principle of Polymorphism, which means, that one task can be performed in many ways.
OOPs restrict direct access to its methods and variables by encapsulating the code and data together.
OOPS Data Abstraction feature is used for hiding internal details and showing the functionality only.