【发布时间】:2014-03-16 07:16:36
【问题描述】:
这是我正在使用的语句,但它说没有匹配的函数可以调用 '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;
【问题讨论】:
-
std::max和std::min在algorithm标头中。 -
我已经使用了#include
,但不会工作 -
如果您发布一个可编译的示例会有所帮助。您帖子中的调用没有任何意义,因为您似乎正在尝试将指针与零进行比较。两个输入必须是完全相同的类型。
-
请贴出完整代码
-
包括该行中使用的变量的声明,尤其是它们的类型。
标签: c++ xcode compiler-errors