fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class IntList
  5. {
  6. private:
  7. int list[1];
  8. public:
  9. IntList() {list[0] = 0;}
  10. int operator[] (const int index) const { return list[index]; }
  11. int& operator[] (const int index) {return list[index];}
  12. };
  13.  
  14. int main(int argc, const char** argv)
  15. {
  16. IntList list;
  17.  
  18. cout << list[0] << endl;
  19. list[0] = 1;
  20. int x = list[0];
  21. cout << list[0] << ", " << x << endl;
  22. return 0;
  23. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
0
1, 1