Function overloading is a C++ programming feature that allows us to have more than one function having same name but different parameter list, when I say parameter list, it means the data type and sequence of the parameters.
Program:
#include<iostream>
using namespace std;
int volume(int l);
double volume(double,int);
long volume(long,int,int);
int main()
{
int x=volume(10);
cout<<x<<endl;
double y=volume(2.5,8);
cout<<y<<endl;
long z=volume(100,75,5);
cout<<z<<endl;
}
int volume(int s)
{
return(s*s*s);
}
double volume(double r,int h)
{
return(3.14*r*r*h);
}
long volume(long l,int b,int h)
{
return(l*b*h);
}
OUTPUT:
BY
REGU RAM SV.
Post a Comment