数组下标: operator[]

数组下标: operator[]#

 1class Widget {
 2 public:
 3  int& operator[](int index) {
 4    return array_[index];
 5  }
 6  int const& operator[](int index) const {
 7    return array_[index];
 8  }
 9
10 private:
11  int array_[100];
12};