fork(2) download
  1. #include <iostream>
  2.  
  3. class DebugMessage
  4. {
  5. private:
  6. std::ostream& stream;
  7. public:
  8. DebugMessage() : stream( std::cout ) { }
  9. virtual ~DebugMessage() { stream << std::endl; }
  10. operator std::ostream&() { return stream; }
  11. };
  12.  
  13. int main(int argc, char *argv[])
  14. {
  15. static_cast<std::ostream&>(DebugMessage()) << "hello" << 42;
  16. return 0;
  17. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
hello42