error C2668: 'M' : ambiguous call to overloaded function

2019-03-25 13:50|来源: 网路

以下是代码:
#include<iostream>
using namespace std;

int M(int a,int b);
float M(float a,float b);
char M(char a,char b);

int main()
{
	float u;
	u=M(5.0,6.0);
	cout<<u<<endl;
	return 0;
}

inline int M(int a,int b)
{
	return  a>b?a:b;
}
inline float M(float a,float b)
{
	return  a>b?a:b;
}
inline char M(char a,char b)
{
	return  a>b?a:b;
}


错误提示为:error C2668: 'M' : ambiguous call to overloaded function
为什么呢?
另外在第十一行 u=M(5.0,6.0); 中如果把 5.0、6.0 分别换成 5、6 就不会报错了,为什么呢?

相关问答

更多