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 const &a, C const &b) { C r; r.n = a.n + b.n; return r; }
  14. friend std::ostream &operator<<(std::ostream &stream, C ob) { stream << ob.n; return stream; }
  15. };
  16.  
  17. int main() {
  18. C s = 0;
  19. for (int n = 0; n <= 10; n++)
  20. s = s + n;
  21. std::cout << s << std::endl;
  22. return 0;
  23. }
  24. /* end */
  25.  
Success #stdin #stdout 0s 16048KB
stdin
Standard input is empty
stdout
55