fork download
  1. #include <iostream>
  2. using std::cout;
  3. using std::endl;
  4.  
  5. #include <string>
  6. using std::string;
  7.  
  8. struct String
  9. {
  10. string s;
  11.  
  12. String( string str ) : s( str )
  13. {
  14. }
  15.  
  16. String operator+( const String &rhs ) const
  17. {
  18. String tmp( s );
  19.  
  20. tmp.s.append( rhs.s );
  21.  
  22. return tmp;
  23. }
  24. };
  25.  
  26. int main()
  27. {
  28. String s1( "123" );
  29. String s2( "456" );
  30. String s3 = s1 + s2;
  31.  
  32. cout << s3.s << endl;
  33.  
  34. return 0;
  35. }
  36.  
  37.  
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
123456