Why operator () [] -> = must be non-static member? [duplicate]
Possible Duplicate:
Why are some operators in C++ only allowed to be overloaded as member functions?
Why operator () [] -> = must be non-static member? Why it can开发者_C百科't be friend?
Because you have to call it on an instance of a class. Take for example the -> operator. How would you propose getting a pointer to the class itself? It doesn't make much sense.
Because it has to be non-static. Simple design decision. Probably because C++ doesn't have the concept of class objects.
精彩评论