Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. Basically it is used to bridge the gap between the real world entity and our code.
Advantages of OOPS
- OOP is faster and easier to execute
- OOP provides a clear structure for the programs
- OOP helps to keep the C++ code DRY “Don’t Repeat Yourself”, and makes the code easier to maintain, modify and debug
- OOP makes it possible to create full reusable applications with less code and shorter development time
Major principles of object-oriented programming system are given below.
- Data Abstraction
Any entity that has state and behavior is known as an object. For example: chair, pen, table, keyboard, bike etc. It can be physical and logical.
A class is a blueprint of a object. For instance, consider a person, he should have a name, dob, address, phone number, etc. And we might need to print/transfer these details, in this case we need functions. Here comes the need of a class.
When one object acquires all the properties and behaviours of parent object i.e. known as inheritance. It provides code reusability. It is used to achieve runtime polymorphism.
When one task is performed by different ways i.e. known as polymorphism. For example: to convince the customer differently, to draw something e.g. shape or rectangle etc.
Hiding internal details and showing functionality is known as abstraction. For example: phone call, we don’t know the internal processing.
Binding (or wrapping) code and data together into a single unit is known as encapsulation. For example: capsule, it is wrapped with different medicines.