Suppose i have declared subscript operators in a class
char& operator[] (int index);
const char operator[](int index) const;
In what condition the second overload is called. Is it only called through a const object
.
In the following scenarios which version of operator will be called.
const char res1 = nonConstObject[10];
nonConstObject[10];