Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error on Xcode "No matching function for call to 'max'"

This is the statement that I'm using but it says that no matching function for call to 'max'

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

Any help would be appreciated.

EDIT

Code

 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;
like image 277
user3317815 Avatar asked Feb 17 '14 05:02

user3317815


1 Answers

max() requires that the first and second arguments are of the same type. extra_charge is a double which results in the first and second arguments having different type. Try:

max((used_minutes-Included_Minutes)*extra_charge,0.0) 
like image 81
Peter R Avatar answered Oct 05 '22 23:10

Peter R