I'm new to C++ and I encountered a case where a script directly prints an output to prompt like this:
cout << setw(10) << Object->GetAuthor().GetId() << " ";
cout << Object->GetDate() << " ";
cout << Object->GetCaseNumber() << " ";
This works in the script and prints to the console, now I would like to save the strings instead of printing it to prompt but the fact is that this are not strings in this sample they could be int variable or other things.
I don't understand why cout << Object->GetType() << " "; works while string x = Object->GetType() doesn't.
And is there a way to save what's being printed to the console as strings?
coutwith a stringstream object, and use itsstrfunction to extract the completed string.