Function Overloading Short & Sweet Query
Code:
#include <iostream>
using namespace std;
int max(int number1,int number2);
int max(float number1,float number2,);
int main()
{
float decimal;
int maxVal= max(5,12);
decimal= max(11.12,6.8); //COMPILE TIME ERROR
}
int max(int number1,int number2)
{
int highest;
if(number1>number2)
highest=number1;
else
highest=number2;
return highest;
}
float max(float number11,float number22)
{
float highest;
if(number11>number22)
highest=number11;
else
highest=number22;
return highest;
}
Compiler gives error saying " ambiguous function overloading" I do not think its ambiguous because int and float data types are totally different. Please exaplain Its compiler bug or what