fork(2) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class MyString
  6. {
  7. std::string value;
  8.  
  9. public:
  10. MyString& operator,(const string& c)
  11. {
  12. value += c + ' ';
  13. return *this;
  14. }
  15.  
  16. friend ostream& operator<<(ostream& o, const MyString& s)
  17. {
  18. o << s.value;
  19. return o;
  20. }
  21. };
  22.  
  23. int main()
  24. {
  25. cout << (MyString(), "hi", "codeisc", "!") << endl;
  26. cout << (MyString(), "hi", "codeisc", '?', "oh no! what happened?") << endl;
  27.  
  28. cin.get();
  29. return 0;
  30. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
hi codeisc ! 
oh no! what happened?