2014-02-17 49 views
3

这是我使用的语句,但它说,对于呼叫没有匹配的功能,“最大”错误在Xcode中“不呼叫到‘最大’匹配功能”

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

任何帮助将是赞赏。

EDIT

代码

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; 
+0

'std :: max'和'std :: min'位于算法标题中。 – Brian

+0

我已经使用#include ,但不会工作 – user3317815

+0

如果您发布可编译示例,这将有所帮助。您的帖子中的调用没有任何意义,因为它似乎是在尝试将指针与零比较。两个输入必须是完全相同的类型。 – shawn1874

回答

6

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

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