Coupon Accepted Successfully!


Key Concepts of Object Oriented Programming

Object oriented programming language is a feature that allows a mode of modularizing programs by forming ory area for data as well as functions that is used as object for making copies of modules as per requirement.


There are several fundamental concepts in object oriented programming. They are shown in Figure and are discussed as follows.

Description: 20900.png

Concepts/elements of object oriented paradigm


Objects are primary run-time entities in object oriented programming.


Objects are primary run-time entities in object-oriented programming. They may stand for a thing that makes sense in a specific application. Some examples are a spot, a person, any data item related to the program including user-defined data types. Programming issues are analyzed in terms of object and the type of transmission between them. Program objects must be selected like the items equivalent to actual world objects. Objects occupy space in memory. Every object has its own properties or features that illustrate what the object can do. An object is a specimen of a class. It can be singly recognized by its name. It declares the state that is shown by the data values of its characteristic at a specific time. The state of the object varies according to the procedure used with it. It is called as the action of the object. The action of the object depends upon the member function defined within its class.

Figure (a) shows some of the objects that we use in our daily life.


(a) Commonly available objects

(b) Representation of an object

Objects communicate with each other by sending messages. An object can be represented by Figure (b).


The name of the above object is city. Its data members are name_of_city, population, and area. The various functions associated with the city are average age, literacy_ rate, and display.


A class is grouping of objects that have the identical properties, common behavior, and shared relationship. A class binds the data and its related functions together.


A class is the accomplishment of abstract data type. It defines the nature and methods that act on the data structure and abstract data type, respectively. Specimens are also called as objects. In other words, a class is a grouping of objects that have identical properties, common behavior, and shared relationship. For example, Tata’s Swift, Maruti’s Alto etc. are the members of a class car.


The entire group of data and code of an object can be built as a user-defined data type using class. Objects are nothing but variables of type class. Once a class has been declared, the programmer can create a number of objects associated with that class. The syntax used to create an object is similar to the syntax used to create an integer variable in C. A class is a model and not a true specimen of the object. Every object has its own value for each of its member variables. However, it shares the property names or operations with other instances of the class. Thus, classes define the characteristic and action of objects.

Description: 14687.png

Objects and their properties

In Figure commonly useful classes are described with their properties and action they perform. For example, a car has properties like company, model and color with which a car can be identified among a number of cars of other properties, and the actions like speed() and average() describes its working.

Classes and their members

Figure describes the classes and related data that come under the different classes.


An operation required for an object or entity when coded in a class is called a method.


An operation required for an object or entity when coded in a class is called a method. The operations that are required for an object are to be defined in the class. All objects in a class carry out certain common actions or operations. Each action needs an object that becomes a function in the class that defines it and is referred to as a method.

In Figure the class and its associated data members and functions are shown in different styles. It is a frequent style of writing a class in the program.

The class A contains private data members and public methods or member functions. Usually, the data members are declared private and methods or member functions are declared as public and they are available outside the class. The data member of any class uses its member functions or methods to perform operations.

Description: 14842.png


Description: 14859.png


Figure (a) and (b) Representation of methods in different manners

Data Abstraction

Abstraction refers to the procedure of representing essential features without including the background details.


Abstraction refers to the procedure of representing essential features without including the background details. Classes use the theory of abstraction and are defined as a list of abstract properties such as size, cost, height, and few functions to operate on these properties. Data abstraction is the procedure of identifying properties and method related to a specific entity as applicable to the application.

A powerful method to achieve abstraction is through the manipulation of hierarchical classifications. It permits us the breaking of semantics of multiple systems into layers by separating them into multiple controllable parts. For example, a computer as shown in Fig. 1.13 is made of various parts such as CPU, keyboard, and so on. We think it as a single unit, but the single unit has several sub-units. They together do the single task. By assembling sub-parts we can build a single system.

Hierarchical abstraction of complicated systems can also be used in computer software. The data from conventional procedure oriented programs can be converted by abstraction mechanism into its partial objects. A series of operation steps may develop a set of messages between these objects. Each object shows its own attributes.

Data abstraction is used to define a data type available in the programming language, called as abstract data type (ADT). It consists of a set of values and a set of operations.

Computer and its parts


The packing of data and functions into a single component is known as encapsulation.


C++ supports the features of encapsulation using classes. The packing of data and functions into a single component is known as encapsulation. The data is not reachable by the outside functions. Only those functions that are able to access the data are defined within the class. These functions prepare the interface between the object’s data and the program. With encapsulation we can accomplish data hiding. Data hiding is an important feature using which an object can be used without the user knowing how it works internally.

In C++ the fundamental of encapsulation is class. A class defines the structure of data and member functions. It is common to all its objects. Class is a logical structure whereas object is a physical actuality. The goal of the class is to encapsulate complication. The class also has a mechanism for hiding the data. Each member in the class may be private or public. Any non-member function cannot access the data of the class. The public section of the class must be mindfully coded not to expose the inner details of the class. Figure explains sections of encapsulation.

Description: 14944.png

Encapsulation: Private and public sections


Inheritance is the method by which objects of one class get the properties of objects of another class.


Description: 23231.png


Inheritance is the method by which objects of one class get the properties of objects of another class. In object oriented programming inheritance provides the thought of reusability. The programmer can add new properties to the existing class without changing it. This can be achieved by deriving a new class from the existing one. The new class will possess features of both the classes. The actual power of the inheritance is that it permits the programmer to reuse a class that is nearly, but not precisely, what he wants, and to tailor the class in such a manner that it does not bring any unwanted incidental result into the rest of the class. Thus, inheritance is the feature that permits the reuse of an existing class to make a new class. Figure shows an example of inheritance.

In Figure, red, yellow and blue are the main colors. The orange is created from the combination of red and yellow, green is created from yellow and blue and violet is created from red and blue. The orange color has attributes of both red and yellow, which produces a new effect. Thus, many combinations are possible.


Polymorphism allows the same function to act in a different way in different classes.


Polymorphism makes it possible for the same functions to act differently on different classes as shown in Figure. It is an important feature of OOP concept. It holds an ability to take more than one form. Polymorphism accomplishes an important part in allowing objects of different classes to share the same external interface. It is possible to code a non-specific (generi(c) interface to a set of associated actions.

Description: 14990.png

Polymorphism in OOP

Dynamic Binding

Binding means connecting one program to another program that is to be executed in reply to the call.


Binding means connecting one program to another program that is to be executed in reply to the call. Dynamic binding is also known as late binding. The code present in the specified program is unknown till it is executed. It is analogous polymorphism.

In Figure polymorphism allows the single object to invoke similar function from different classes. The program action is different in all the classes. At execution time, the code analogous to the object under the present reference will be executed. The reader is advised to refer polymorphism chapter for more details.

Message passing

An object oriented programming includes objects. The objects communicate with one another. The programming with these objects should be followed with following steps.

  1. Declaring classes that define objects and their actions.
  2. Declaring objects from classes.
  3. Implementing relation between objects.

Data is transferred from one object to another object. A message for an object is the demand for implementation of the process. Message passing consists of indicating the name of the object, function, and required data elements (Figure). Objects can be created, released, and interacted with each other. An object is workable, as long as it is active. In object oriented programming there is a panorama of independent objects that communicate with each other by swapping messages. Objects invoke member functions. They also negate if the calling object is not a member of the same class. Thus a message is a solicitation to an object to call one of its member functions. A message contains name of the member function and parameters of the function. Execution of member function is just a response generated due to receipt of a message. It is possible when the function and the object are of the same class.

Description: 15006.png

Message Passing


Object oriented technology allows reusability of the classes by extending them to other classes using inheritance.


Object oriented technology allows reusability of the classes by extending them to other classes using inheritance. Once a class is defined, the other programmer can also use it in their programs. The programmer can also add new feature to the derived classes. The verified and checked qualities of base classes need not to be redefined. Thus, the reusability saves the time. In Figure, class A is reused and class B is created. Again class B is reused and class C is created.

Description: 15027.png



In OOP, two classes can be joined in two ways: (a) Inheritance, (b) Delegation.
Both these ways provide reusability of the class.

In Inheritance one class can be derived from the other class. The relationship between these two classes is called as kind of relationship. For example if class Y is derived from class X, then class Y is known as kind of X. Figure (a) explains this point.

Description: 23179.png

Relationships between two classes:
(a) Kind of relationship (Inheritance)
(b) has a relationship (Delegation)


The second type of relationship is has a relationship. When object of one class is used as data member in the other class, such composition of objects is known as delegation. As shown in Figure (b) class C has two data members. These two data members are objects of class A and B, such relationship between the classes in known as has a relationship.


The software components of a program have more than one version depending on the data types of arguments. This feature allows declaration of variables without specifying exact data type. The compiler identifies the data type at run time. The programmer can create a function that can be used for any type of data. The template feature in C++ allows generic programming.

Test Your Skills Now!
Take a Quiz now
Reviewer Name