what is polymorphism?

 

Polymorphism

Polymorphisms menace the ability to take more then one form. The operation may perform different behavior in different instance. The behavior depends upon the types of data used in the operation.

For example.. Consider the operation of addition, for two numbers the operation will generate sum in the operant are string then the operation would produce therd string by concatenation.

types of overloading.

Operator overloading.

Defenation:-function name is same but parameters are different are none as function overloading.

Example:--

int  i;

i=10+20; we get the answer 30.

Char * ch;

ch="abc"+"xyz"; we get the answer abcxyz.

Function overloading

Defenation:-operators are performing the tasks on different operant is none as operator overloading.

For example:-

Int sum (int,int);

int sum(int,int,int);

float sum(float,float);

void sum()

{sum (10,20);

sum(10,20,30);

sum(10.2,20.2);}

int sum(int a,int b)

{

return a+b;

} int sum (int a,int b,int c)

{ return a+b+c; }

float susm(float a, float b)

{return a+b;}

In above example hear one function called sum and it is use for three time in to program and it Perform different tasks, first sum function will sum two integers values ,second is  do sum of Three integer values and at last it will do the sum of the two float values.

 

 

 

 


Average Rating (0)
by suraj   dube  in C++  on 7/2/2015 1:08:38 AM  


Post Your Comment
*