gpt4 book ai didi

c++ - Xcode 错误 "No matching function for call to ' max'"

转载 作者:可可西里 更新时间:2023-11-01 18:20:11 25 4
gpt4 key购买 nike

这是我正在使用的声明,但它说没有匹配函数来调用“max”

max((used_minutes-Included_Minutes)*extra_charge,0) 

如有任何帮助,我们将不胜感激。

编辑

代码

 int used_minutes; const int Included_Minutes = 300;
double total_charge, extra_charge;
cout << "Enter the number of phone call minutes: ";
cin >> used_minutes;
cout <<"Number of phone call minutes used - included in the base plan: " << min(used_minutes,Included_Minutes) << endl;
cout <<"Number of phone call minutes used - not included in the base plan: "<< max(used_minutes-Included_Minutes,0) << endl;
extra_charge = 0.10;
cout <<"Cost of excess phone call minutes: $"<<fixed << setprecision(2) << max(used_minutes-Included_Minutes)*extra_charge, 0) <<endl;

最佳答案

max() 要求第一个和第二个参数的类型相同。 extra_charge 是一个 double,它导致第一个和第二个参数具有不同的类型。尝试:

max((used_minutes-Included_Minutes)*extra_charge,0.0) 

关于c++ - Xcode 错误 "No matching function for call to ' max'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21821527/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com