//C++ program - Demonstrates that default values can not be used in conjunction with Overloaded functions (PROGRAM DOESN'T COMPILE: Gives // // // Error)
#include
using namespace std;
int Volume(int, int=25, int = 1);
float Volume(float,float);
int main()
{
int length = 100, width = 50, height = 2;
int volume;
volume = Volume(length, width, height);
cout <<"First volume with all parameters = " << volume << endl;
volume = Volume(length, width);
cout <<"Second volume with one default = " << volume << endl;
volume = Volume(length,width);
cout <<"Third volume with two defaults = " << volume << endl;
cout << "Overloading example = " << Volume(45.0,4.5) << endl;
system ("pause");
return 0;
}
int Volume(int len, int wid, int hit)
{
return(len*wid*hit);
}
float Volume(float x, float y)
{
return(x/y);
}
Note: In the program, After #include "iostream" tag is there...
But it is not seen as the post is considered as a HTML post...
So please don't forget this point...
The original file is uploaded as attachment...
Check that also...
With Regards,
ZORO
IIT Madras - CSE