Tuesday 1 July 2014

Basic Concept of Function Overloading With Example


Concept of Function Overloading With Example


The very basic definition of function overloading in C++ is a function name having several definition that are differentiable by the number or the types of their arguments , is known as function overloading.


For Example 

The following example in which the code overloads a function area to find the values of area of circle ,rectangle and triangle.


float area(float r)
{
return 3.1*r*r;
}
float area (float len,float bre)
{
return len*bre;
}
float area(float side1, float side2, float side3)
{
float & = (side1+side2+side3)/2;
float ar = sqrt(&*(&_side1)*(&*(&_side2)*(&*(&_side3));
return ar;
}

No comments:

Post a Comment