Thursday, 7 March 2013

c++ program on function overloading (simple)

#include<iostream.h>
#include<conio.h>

class ovrlod
{
public :
int volume(int);
double volume(double,int);
long volume(long,int,int);
};

int ovrlod::volume(int s)
{
return (s*s*s) ;
}

double ovrlod :: volume (double r,int h)
{
return(3.154*r*h);
}

long ovrlod :: volume(long l,int b,int h)
{
return(l*b*h)  ;
}

void main()
{
ovrlod x;
cout<<"volume of cube =" <<x.volume(10) ;
cout<<"volume of cylinder ="<< x.volume(2.5,8);
cout<<"volume of rectangle ="<< x.volume(100,75,15);
getch();
}

No comments:

Post a Comment