fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class MyClass
  5. {
  6. public:
  7. void operator[](int n)
  8. {
  9. cout<<"In [], index = " << n;
  10. }
  11. void at(int n) {(*this)[n];}
  12. };
  13.  
  14.  
  15.  
  16. int main()
  17. {
  18. MyClass *a=new MyClass;
  19. a->at(2);
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
In [], index = 2