Array operator [] overloading const and non-const versions
问题 I got an assignment to implement a template array class. One of the requirement is to overload the [] operator. I made this two const and non-const version which seems to be working fine. const T& operator[](const unsigned int index)const and T& operator[](const unsigned int index) My question is how will the compiler know which one to run when i will do something like: int i=arr[1] On a non-const array? 回答1: The non-const function will always be called on a non-const array, and the const