I have a simple class
class Array
{
public:
Array();
~Array();
// Dereferencing operators
int operator[](std::size_t index) const;
int& operator[](std::size_t index);
}
My question is, under what condition is int operator[](std::size_t index) const
called? How can I force C++ to call int operator[](std::size_t index) const
instead of int& operator[](std::size_t index)
? What would happen if I only implement one of the operators?