To add to what Greg has said: when you call FindArea, you are passing it two integer values:
FindArea(rad, heigh)
The first definition accespts three parameters with the last one being optional, it matches:
int FindArea(int radius, int height, int Pi = 3.1415)
But ... the second definition can also take two integer parameters:
int FindArea(int radius, int Pi = 3.1415)
So the system isn't sure which one you meant to call, and won't compile your code unless it decided wrongly!
There are also other problems with your code:
int FindArea(int radius, int Pi = 3.1415)
Will give you a defaulted value for Pi of three - which will create some very odd circles ...
If you want to pass a floating point value, you need to define your function as accepting a floating point value - and you probably want to return a floating point value as well!
double FindArea(int radius, int height, double Pi = 3.1415)
{
return Pi * radius * radius * height;
}
double FindArea(int radius, double Pi = 3.1415)
{
return 4 * Pi * radius * radius * radius / 3;
}
In fact, that cures your problem as well - because now when you try to call your function like this:
FindArea(rad, heigh)
Only the first definition matches, so the call is no longer ambiguous.
But ... you have to ask yourself why are you passing Pi as a value at all? It's is a universal constant and really can't be changed! :laugh: