[ create a new paste ] login | about

Link: http://codepad.org/QZZAUWC9    [ raw code | output | fork ]

C++, pasted on Jun 2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
class C {
  int n;
public:
  C(int n) : n(n) { }
  C &operator()(int n) {
    this->n += n;
    return *this;
  }
  friend std::ostream &operator<<(std::ostream &s, C c) {
    s << c.n;
    return s;
  }
};

int main() {
  C c(0);
  std::cout << c(1)(2)(3)(4)(5)(6)(7)(8)(9)(10) << std::endl;
  return 0;
}
/* end */


Output:
1
55


Create a new paste based on this one


Comments: