fork(2) download
  1. #include <iostream>
  2.  
  3. class InnerPoint
  4. {
  5. private:
  6. int value;
  7.  
  8. public:
  9. InnerPoint(int value) : value(value) { }
  10.  
  11. int operator[](int b)
  12. {
  13. return value * b;
  14. }
  15. };
  16.  
  17. class Point
  18. {
  19. private:
  20. int x;
  21. int y;
  22.  
  23. public:
  24. Point(int x, int y) : x(x), y(y) { }
  25.  
  26. InnerPoint operator[](int a)
  27. {
  28. int value = x + y + a;
  29.  
  30. return InnerPoint(value);
  31. }
  32. };
  33.  
  34. int main()
  35. {
  36. Point point(2, 4);
  37.  
  38. std::cout << point[3][5] << "\n";
  39. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
45