fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Str
  6. {
  7. public:
  8. string li;
  9. string mi;
  10. Str( string a, string b );
  11. Str operator +( const Str & c );
  12. };
  13. Str::Str( string a, string b )
  14. {
  15. li = a;
  16. mi = b;
  17. }
  18.  
  19. Str Str::operator +( const Str & c )
  20. {
  21. Str st( " ala ", " ola " );
  22. st.li = st.li + c.li;
  23.  
  24. return st;
  25. }
  26. int main()
  27. {
  28. Str sr( " kaktus ", " torba " );
  29. Str s( " wrzawa ", " slonecznik " );
  30. sr = sr + sr;
  31. s = s + s;
  32. cout << sr.li << endl;
  33. cout << s.li << endl;
  34. cin.get();
  35. return 0;
  36. }
Success #stdin #stdout 0s 3036KB
stdin
Standard input is empty
stdout
 ala  kaktus 
 ala  wrzawa