WRITE A PROGRAM FOR FUNCTION OVERLOADING IN C++

 Que - make a program for function overloading?

#include<iostream>
using namespace std;

class krishna
{
  public:
  void volume (int radius)
  {
    float pi=3.14,cons =4.186, volume;
   volume =pi*cons*radius*radius*radius;
    cout<<"volume of sphere is :- "<<volume ;
}
void volume (float length)
  {
    float  volume;
   volume =  length*length*length ;
    cout<<"volume of cube is :- "<<volume ;
}
void volume (int len,int wid,int hei)
  {
    float  volume;
   volume =len*wid*hei;
    cout<<"volume of cuboid is :- "<<volume ;
}
};
int main()
{
    krishna ob;
    ob. volume (5.1f); // for using float value we need f like -5.1(f)
    return 0;
}

Result:-



Post a Comment

Previous Post Next Post