Write your question here.
Can you please tell me what I'm doing wrong here?
#include <iostream>
using namespace std;
template <class T>
T max (T x, T y)
{
string result;
if (x > y)
cout << x << " is bigger than " << y;
else if (x == y)
cout << x << " is equal to " << y;
else
cout << y << " is bigger than " << x;
}
int main()
{
double x = 5.6, y = 4.4;
max (x, y);
}
There already are functions named std::max, and by writing usingnamespace std; , if any of them are visible to the compiler (especially the one that takes two double parameters), it won't know which function you mean.
Your code is a perfect demonstration of why we say don't write usingnamespace std;https://ideone.com/zuAjT3