2014-02-17 51 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)