if I have
int arr[10] = { 1,2,3,4,5 };
std::cout << arr[1,4] << "\n";
the code compiles fine and returns 5 (arr[4]). This is true even with overloads of operator[] in different classes. In other words if I have:
class A{
public:
int operator[](int i) {return i;}
}
A a;
std::cout<<a[1,4];
I will get 4 (a[4]). No compilation problem. Is there a way to avoid potential errors by a compilation error in such cases?