+ 2

Printing a string from a class

can I print a string from a void function in a class? https://code.sololearn.com/cF6pb2R26zAA/?ref=app

27th Oct 2017, 8:57 PM
acoolwinter
acoolwinter - avatar
7 Answers
+ 9
Here is it fixed. There are numerous errors. *Manually calling constructor *Returning a value from constructor (cout can not be returned like this) *not supplying a value to constructor during initialisation https://code.sololearn.com/cJvjUbtdqVUH/?ref=app
27th Oct 2017, 10:19 PM
jay
jay - avatar
+ 9
yes. At least one of the functions will be required to return a string though. example string functionOne () { return "Hello"; } void functionTwo () { string output = functionOne (); cout << output << " this should work"; }
27th Oct 2017, 10:31 PM
jay
jay - avatar
+ 8
Also you could use this method. https://code.sololearn.com/cTkO1CvaPQo8/?ref=app
27th Oct 2017, 10:45 PM
jay
jay - avatar
+ 5
You are welcome!
27th Oct 2017, 11:24 PM
jay
jay - avatar
+ 3
Yes. Your compile error is due to defining Email() without implementing it. Delete line 8 and it runs.
27th Oct 2017, 9:08 PM
John Wells
John Wells - avatar
+ 1
Can i append a string from one function to another function producing a string?
27th Oct 2017, 10:27 PM
acoolwinter
acoolwinter - avatar
+ 1
Thank you. my goal is to put a time stamp next to a string, and you helped me a lot.
27th Oct 2017, 11:23 PM
acoolwinter
acoolwinter - avatar