This blog will give good idea about the concepts of the Object Oriented Programming using C++ language example.
Saturday, October 28, 2017
Polymorphism
Polymorphism:
o Polymorphism is a Greek term which means ability to take more than one form.
o For example, + is used to make sum of two numbers as well as it is used to combine two strings.
o This is known as operator overloading because same operator may behave differently on different instances.
o Same way functions can be overloaded. For example, sum () function may takes two arguments or three arguments etc. i.e. sum (5, 7) or sum (4, 6, 8).
Dynamic Binding or Late Binding
Dynamic binding:
o Binding means link between procedure call and code to be execute.
o Dynamic binding means link exist between procedure call and code to be execute at run time when that procedure is call.
o It is also known late binding.
o It is generally use with polymorphism and inheritance.
o For example, complier comes to know at runtime that which function of sum will be call either with two arguments or with three arguments.
Message Passing
Message Passing:
o Objects can communicate with each others by passing message same as people passing message with each other.
o Objects can send or receive message or information.
o Message passing involves name of object, name of function (message) and information to be send.
o For example, student.mark(name). Here student is object, mark is message, name is information.
Benefits of OOP
Benefits of OOP
o Following are the benefits of object oriented programming language.
o User can create new data type or users define data type by making class.
o Code can be reuse by using inheritance.
o Data can be hiding from outside world by using encapsulation.
o Operators or functions can be overloaded by using polymorphism, so same functions or operators can be used for multitasking.
o Object oriented system can be easily upgrade from small system to large system.
o It is easy to partition work for same project.
o Message passing techniques make communication easier.
o Software complexcity can be easily managed.
o Maintenances cost is less.
o Simple to implement.
Application of OOP
o Following are the applications for object oriented language.
o Real time systems
o Simulation and modeling
o Object oriented database
o Hypertext, hypermedia and expertext
o AI and expert systems
o Neural network and parallel programming
o Decision support system
o Office automation system
o CIM / CAM / CAD systems
Example of Simple C++ Program
[1] WAP to print message on screen.
#include<iostream.h>
#include<conio.h>
void main()
{
cout<<”This is first program in c++”;
cout<<”\n welcome”;
getch();
}
[2] WAP to print value of variables.
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
a = 50;
cout<< ”\n value of a = ” << a;
getch();
}
Subscribe to:
Posts (Atom)
