What is object oriented programming
- Object-oriented programming shifts the focus of attention to the objects, that is, to the aspects on which the problem is centered.
- Central to C++ is object-oriented programming (OOP). As just explained, OOP was the impetus for the creation of C++.
- Because of this, it is useful to understand OOP’s basic principles before you write even a simple C++ program.
- An object representing an account in a program will have properties and capacities that are important for account management.
- Object-oriented programming took the best ideas of structured programming and combined them with several new concepts. The result was a different and better way of organizing a program.
- In the most general sense, a program can be organized in one of two ways: around its code (what is happening) or around its data (who is being affected).
- Using only structured programming techniques, programs are typically organized around code. This approach can be thought of as “code acting on data.”
- Object-oriented programs work the other way around. They are organized around data, with the key principle being “data controlling access to code.”
- In an object-oriented language, you define the data and the routines that are permitted to act on that data. Thus, a data type defines precisely what sort of operations can be applied to that data.
- To support the principles of object-oriented programming, all OOP languages, including C++, have three traits in common: Encapsulation, Polymorphism, and Inheritance.
Advantages of OOP
Object-oriented programming offers several major advantages to software development:
- Reduced susceptibility to errors: an object controls access to its own data. More specifically, an object can reject erroneous access attempts.
- Easy re-use: objects maintain themselves and can therefore be used as building blocks for other programs.
- Low maintenance requirement: an object type can modify its own internal data representation without requiring changes to the application.
Feature of Object Oriented Programming
- It gives stress on the data items rather than function.
- It makes the complete program/problem simpler by dividing it into a number of objects.
- The objects can be used as a bridge to have data flow from one function to another.
- You can easily modify the data without any change in the function.