(January 26, 2018 at 10:06 pm)KevinM1 Wrote: So, since cout doesn't return and simply spits things out to standard output, it will give you a prompt each loop.
std::cout should always return the std::ostream& of itself. It is used to concatenate ostream operations like:
std:: cout << something << another_thing << one_other_thing << std::endl;
Yep, instead of adding a carriage return and line feed when cout-ing, one should use std::endl. It's more portable code and flushes the stream, making it safer, thread wise.
Lets say I have a class called LastPoet, and I wanted to overload the ostream operator to print whatever that class does into whatever cout is defined to do (usually console out). I needed to declare inside the class declaration:
friend std::ostream& operator<<(std::ostream& out, const LastPoet& obj); // that return is usefull, but not to boolean evaluation