fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. struct Logger
  5. {
  6. std::string header;
  7. Logger(std::string h) : header(h) {}
  8.  
  9. friend std::ostream& operator<<(std::ostream& os, const Logger& log)
  10. {
  11. os << log.header;
  12. return os;
  13. }
  14. };
  15.  
  16. int main()
  17. {
  18. Logger t("INFO: ");
  19. std::cout << t << "AB:CD:EF:12:34:56 associated\n";
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
INFO: AB:CD:EF:12:34:56 associated