0
Facing little issue,help
#include <iostream> #include <string> using namespace std; //complete the function with one default argument void printOrder(string order="Blacktea",string friendOrder ){ cout<<order<<friendOrder; } int main() { //getting coffee type string friendOrder,order ; cin >> friendOrder; cout<<friendOrder<<endl; printOrder(friendOrder); printOrder(order); return 0; }
2 odpowiedzi
+ 2
Arguments with default values must come last in the argument list, i.e. there may be no argument without a default value after one with a default value. Simply switching the arguments should do the trick.
0
void printOrder(string order,string friendOrder="Blacktea"){
cout<<order<<friendOrder;
}
Didn't understand this question, but code works for me. I've set the value "Blacktea" to the second default argument.
void printOrder(string order,string friendOrder="Blacktea"){
cout<<order<<friendOrder;
}