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; }

4th Jul 2021, 6:40 PM
Chinmay Anand
Chinmay Anand - avatar
2 Réponses
+ 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.
4th Jul 2021, 7:07 PM
Shadow
Shadow - avatar
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; }
4th Jul 2021, 7:08 PM
Maksat Ramazanov
Maksat Ramazanov - avatar