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. friend bool operator==(C const &a, C const &b) { return (a.n == b.n); }
  13. C operator+=(C const &ob) { this->n += ob.n; return *this; }
  14. friend std::ostream &operator<<(std::ostream &stream, C const &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 = 0;
  20. for (int n = 1; n <= 10; n++)
  21. s += n;
  22. std::cout << s << std::endl;
  23.  
  24. s = 0;
  25. for (int n = 1; n <= 100; n++)
  26. s = n + s;
  27. std::cout << s << std::endl;
  28.  
  29. std::cout << (2 == s) << std::endl;
  30. return 0;
  31. }
  32. /* end */
  33.  
Success #stdin #stdout 0s 15224KB
stdin
Standard input is empty
stdout
55
5050
0