why subscript operator ([]) must be overloaded in member function?? one may say that because it will take one argument , but operation needs two operands...one the base address and second is index(offset).
cdnt it be , if cd have been treated like binary operator as well like this
class a
{
int arr[10];
friend int & operator(a &, int);
}
a .... where a is the first operand and i is the second....
so the friend function wd work like this
int & operator[](a& temp,int index)
{int a[] = a.arr;
return a[index];
}
now the problem is, y this implementation is not valid? y we have to do this in a member function only??