O'Reilly logo
  • Li Zheng thinks this is interesting:

TextBlock tb("Hello");
std::cout << tb[0];                   // calls non-const
                                            // TextBlock::operator[]
const TextBlock ctb("World");
std::cout << ctb[0];                  // calls const TextBlock::operator[]

From

Cover of Effective C++: 55 Specific Ways to Improve Your Programs and Designs, Third Edition

Note

What if need non-const return type for const object?