Object Oriented Programming Approach in C++

The Object Oriented Programming Approach came into existence to remove some of the flaws encountered in the conventional programming approach for designing large and complex programs. Unlike the conventional programming approach, the object oriented approach lays more emphasis on data rather than functions and does not allow data to be accessed freely in the system. The term Object Oriented Programming was originally given by Xerox PARC. The use of  Object Oriented Programming speeds up the program development process, improves maintenance and enhances reusability of programs.

The basic  principle of the Object Oriented Programming approach is to combine both data and functions that operate on that data into a single unit. Such a unit is called an object. Function is the only way to access the data of an object. This secures data from any accidental modification from the outside function.

The Object Oriented Programming approach decompose a problem into number of units called object.


Data of an object can be accessed only by the function of that object. Also different objects in the system communicate with each other by calling the functions of other objects.

The Object Oriented (OO) problem solving approach works very similar to the way how human solve problem of an organization i.e it is very close to reality. To explain this fact consider the same example of automating the general office department, account office department and library department of a college. The OO programming approach starts to solve this problem by first identifying all possible real life objects needed for the solution of the given problem. Dividing the existing problem into objects make it easier to understand and control the organisation activities and  help in maintaining the integrity of the system.

Here, the different departments such as general office department, account office department and library department represents objects. Each department maintains their own information (data) and perform various activities (functions) associated with a department. For example - The Account Office Department maintain information regarding the fees and fine details of a student and perform various activities like calculating fine of a student, maintaining list of part payment students etc. Similarly, the General Office department maintains information regarding the basic and leave the details of the students and perform various activities like getting information about a particular student, getting leave details of a particular student etc. In the same way, the library department maintains the information regarding books basic information, issue details of the books and perform activities like availability of books, status of a particular book and so on.

Therefore, it becomes clear that data on an object can only be accessed and manipulated by functions related to that object and not by other objects. For example - student basic and student leave details data of General Office object can only be accessed by the functions (student_info, student_leave etc) of that object and not by the functions of account office object and library department object.

All these objects are connected together in a similar way as these departments are connected in real life. For example - In real life, one of the activities (function) performed by the account office is to issue roll number to the student before the final examination. To perform this activity Account office need to know the attendance details from the General Office and clearance details about the books from the Library Department. So to access this information, the Account office employee will not directly access the file cabinets of the other departments of the system, instead it sends a memo to appropriate person in the other department and then wait for that person to access data and send you reply with the information that you want. This ensures that data is accesses accurately and is not corrupted by unknown or unauthorized persons. In the similar way, to perform a roll_issue function of the Account office object, it will call the required function of the general office object and library department object so as to get the required information.

When a function of one object calls a function of other object, it is interpreted as sending message to other objects. So in a Object Oriented system, the objects interact with each other by sending messages and receiving responses.

The objects internal structure (what data it maintains, what is the logic of making function) is totally hidden from the user. From the above discussion, we conclude that OOP is an approach of an organisation.

The programming languages that follows the Object Oriented Approach are C++, Smalltalk, Java, Ada, Simula, Eiffel, C# (C Sharp) etc.

Most Important Features of Object Oriented Programming Approach :-

  • It lays more emphasis on data rather than functions as data is not available globally.
  • Data and Functions that operate on that data are encapsulated together into a single unit called an Object. It restricts data to be freely accessed by other objects in the system and thus maintains the security and integrity of the data.
  • Programs are divided into objects and not functions. 
  • It lays more emphasis on what to do and not how to solve a given problem. The OO approach starts first by identifying all the objects and their purpose without dealing with the implementation details.
  • The OO approach represents the real world modelling. In other words, the way the problem is solved using this approach is close to reality. It is an approach of an organisation.
  • Objects in the system communicate with each other using the concept of message passing. 
  • It follows the Bottom-up approach in which we divide the problem to be solved into very small and elementary building blocks known as objects. There after, these building blocks are used to design one level higher building blocks upto the point where one building blocks actually solve your problem with the help of others.
  • Using this approach, complex user defined data types can be created.
  • Modification and maintenance of a program is very easy as if you want to modify the data in an object then only functions of that object needs to be written.
  • It is easy to understand the structure and the working of the complex system.
  • It supports reusability of code which is the basic need of today's programming development.

Post a Comment