0
Exercise 41.2: Default arguments
So far all I am getting is this: Input Sandwich Your Output Sandwich Expected Output Black tea Sandwich #include <iostream> #include <string> using namespace std; //complete the function with one default argument string printOrder(string x = "Black tea") { return x; } int main() { //getting coffee type string friendOrder; cin >> friendOrder; cout << printOrder(friendOrder) << endl; return 0; } How do you change the rightmost arguments, while still allowing the leftmost arguments to stay as defaults? Thanks!
1 Odpowiedź
+ 1
Default Arguments in C++ should be the rightmost, if you want other arguments then it should be on left side. In your case, add another argument while rightmost being default argument and then print both the strings in function or concat them and return.