Where is the error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
4 Answers
+ 2
Default values can only be placed on latter parameters, e.g. func(int a, int b = 42). You don't have data type for the second parameter. To print 2 strings, use cout << string1 << string2;
17th Jan 2021, 11:12 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
zaya1235 CarrieForle just said, "default values can only be placed on latter parameters". Example: func(int a, int b = 1) is valid, but func(int b = 1, int a) is invalid For the same reason, you code is invalid. void printOrder(string hisOrder, string my="Black tea") is valid, but your function definition is invalid.
17th Jan 2021, 11:28 AM
XXX
XXX - avatar
0
CarrieForle so it should be like this void printOrder(string my="Black tea", string hisOrder ) { cout << my << hisOrder ; }
17th Jan 2021, 11:23 AM
zaya1235
zaya1235 - avatar
0
CarrieForle XXX thank you👁️💋👁️
17th Jan 2021, 11:33 AM
zaya1235
zaya1235 - avatar