fork download
  1. #include <iostream>
  2.  
  3. class C {
  4. private:
  5. int n;
  6. public:
  7. C() {}
  8. C(const C &ob) { this->n = ob.n; }
  9. C(const int n) { this->n = n; }
  10. ~C(){}
  11. C &operator=(const C &ob) { this->n = ob.n; return *this; }
  12. bool operator==(const C &ob) /* const */ { return (this->n == ob.n); }
  13. friend C operator+=(C &a, C const &b) { a.n += b.n; return a; }
  14. friend std::ostream &operator<<(std::ostream &stream, C ob) { stream << ob.n; return stream; }
  15. friend C operator+(C const &a, C const &b) { C s; s = a; s += b; return s; }
  16. };
  17.  
  18. int main() {
  19. C s;
  20. for (int n = 1; n <= 10; n++)
  21. s = s + n;
  22. std::cout << s << std::endl;
  23. return 0;
  24. }
  25. /* end */
  26.  
Success #stdin #stdout 0s 15224KB
stdin
Standard input is empty
stdout
55