Sunday 5 January 2014

Function Overloading

//Function overloading refers to use of same thing for different purposes

#include<iostream.h>
#include<conio.h>
int volume(int s)
{
return(s*s*s);
}
double volume(double r,double h)
{
return(3.414*r*r*h);
}
float volume(float l,float b,float h)
{
return(l*b*h);
}
void main()
{
clrscr();
cout<<"volume of cube is:"<<volume(2)<<"\n";
cout<<"volume of cylinder is:"<<volume(3.4,2.1)<<"\n";
cout<<"volume of cuboid is:"<<volume(1.5,2.5,3.5);
getch();
}

No comments:

Post a Comment