Function Overloading

#include<iostream.h>
#include<conio.h>
class shapes
 {
     public:
 int shape(int);
 int shape(int,int,int);
 float shape(float,float);
 double shape(float);
 };
int shapes::shape(int a)
 {
int cube;
cube=a*a*a;
cout<<"The result of cube is:";
cout<<cube;
return 0;
 }
int shapes::shape(int l,int b,int h)
 {
int rec;
rec=l*b*h;
cout<<"The result of Rectangle is:";
cout<<rec;
return 0;
 }
float shapes::shape(float r,float h)
 {
float cone;
cone=(0.33*3.14)*r*r*h;
cout<<"The result of cone is:"<<cone;
return 0;
 }
double shapes::shape(float r)
 {
double sphere;
sphere=((4/3)*3.14*r*r*r);
cout<<"The result of sphere is:"<<sphere;
return 0;
 }
void main()
 {
shapes s;
int i,l,b;
float h,r;
cout<<"Enter the value of i:";
cin>>i;
s.shape(i);
cout<<"Enter the value of length,breath,height:";
cin>>l>>b>>h;
s.shape(l,b,h);
cout<<"Enter the value of arc:";
cin>>r;
s.shape(r,h);
s.shape(r);
getch();
 } 

No comments:

Related Posts with Thumbnails