为了账号安全,请及时绑定邮箱和手机立即绑定

错误:2 overloads have similar conversions

错误:2 overloads have similar conversions

梦里花落0921 2022-07-07 11:07:49
#include "stdafx.h"#include "iostream.h"#include "math.h"float dis(int a, int b, int c,int d){return (float)sqrt((a-c)*(a-c)+(b-d)*(b-d));}double dis(double a,double b,double c,double d){return sqrt((a-c)*(a-c)+(b-d)*(b-d));}void main (){cout<<"点(0,0)与点(3,4)的距离为:"<<dis(0,0,3,4)<<endl;cout<<"点(11.2,-25)与点(0.33,11.22)的距离为:"<<dis(11.2,-25,0.33,11.22)<<endl;}
查看完整描述

1 回答

?
慕森卡

TA贡献1806条经验 获得超8个赞

//#include "stdafx.h"
#include "iostream.h"
#include "math.h"

float dis(int a, int b, int c,int d)
{
return (float)sqrt((a-c)*(a-c)+(b-d)*(b-d));
}

double dis(double a,double b,double c,double d)
{
return sqrt((a-c)*(a-c)+(b-d)*(b-d));
}
void main ()
{
cout<<"点(0,0)与点(3,4)的距离为:"<<dis(0,0,3,4)<<endl;
cout<<"点(11.2,-25)与点(0.33,11.22)的距离为:"<<dis(11.2,(double)-25,0.33,11.22)<<endl;
}
这样就能通过.你用dis(11.2,-25,0.33,11.22)是想调用double dis.但是你赋值里面有个-25,可能系统默认为int型,所以系统没找到相应的dis函数.所以你给系统一点提示.强制装换-25为double型



查看完整回答
反对 回复 2022-07-11
  • 1 回答
  • 0 关注
  • 89 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信