fork download
  1. #include <iostream>
  2.  
  3. class Test
  4. {
  5. struct Impl
  6. {
  7. int a;
  8. int operator[](int b)
  9. { return a * b; }
  10. };
  11. public:
  12. auto operator[](int a)
  13. { return Impl{a}; }
  14. };
  15.  
  16. int main() {
  17. Test data;
  18. std::cout << data[7][6] << std::endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 4252KB
stdin
Standard input is empty
stdout
42