fork(2) download
  1. #include <iostream>
  2.  
  3. class Array {
  4. private:
  5. int *ptr;
  6. public:
  7. Array() { ptr = new int[10]; }
  8. ~Array() { delete [] ptr; }
  9. int& operator[](int index) const { return ptr[index]; }
  10. };
  11.  
  12. int main() {
  13. const Array arr;
  14. arr[0] = 5;
  15. std::cout << arr[0] << std::endl;
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 4476KB
stdin
Standard input is empty
stdout
5