[ create a new paste ] login | about

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

C++, pasted on Nov 5:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>

class Hoge {
private:
  int hoge;
public:
  Hoge() : hoge(0) {}
  Hoge(int hoge) : hoge(hoge) {}
  friend Hoge operator+(Hoge &a, Hoge &b) { Hoge hoge; hoge.hoge = a.hoge + b.hoge; return hoge; }
  friend Hoge operator+(Hoge &a, int n) { Hoge hoge; hoge.hoge = a.hoge + n; return hoge; }
  friend std::ostream &operator<<(std::ostream &s, Hoge hoge) { return s << hoge.hoge; }
};

int main() {
  Hoge a(1), b(2);
  std::cout << a + b << std::endl;
  std::cout << a + 5 << std::endl;
  return 0;
}


Output:
1
2
3
6


Create a new paste based on this one


Comments: