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