fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Foo;
  5. class Bar;
  6. class Hoge;
  7.  
  8. class Foo
  9. {
  10. int v;
  11. public:
  12. Foo(int n) { v = n; }
  13. int getV() const { return v; }
  14. void setV(int n) { v = n; }
  15. };
  16.  
  17. class Bar
  18. {
  19. int v;
  20. public:
  21. Bar(int n) { v = n; }
  22. int getV() const { return v; }
  23. };
  24.  
  25. Foo operator + (const Foo& foo, const Bar& bar) {
  26. Foo sum(foo.getV() + bar.getV());
  27. return sum;
  28. }
  29.  
  30. Foo& operator ++ (Foo& foo, int) {
  31. foo.setV(foo.getV() + 1);
  32. return foo;
  33. }
  34.  
  35. int main() {
  36.  
  37. Foo foo(123);
  38. Bar bar(900);
  39.  
  40. foo++;
  41.  
  42. Foo sum = foo + bar;
  43.  
  44. cout << sum.getV() << endl;
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
1024