in a method PrintName , if i want to print name if i use " cout<<name;" it works , but not if i use " return name". Why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

in a method PrintName , if i want to print name if i use " cout<<name;" it works , but not if i use " return name". Why?

https://code.sololearn.com/cjj8nNJa5ZOb/?ref=appif

15th Apr 2023, 1:58 PM
juan
juan - avatar
2 Answers
+ 5
If you want to use return name, you have to change the return type of the method printNane , from void to string. The cout only prints on screen, the return returns something which is different. https://code.sololearn.com/cUxl7vG6Hfo0/?ref=app
15th Apr 2023, 2:13 PM
Black Winter
+ 2
thank you! i was confused whith that
15th Apr 2023, 5:18 PM
juan
juan - avatar