[comp.lang.c++] subscription and function call operators

kanner@Apple.COM (Herbert Kanner) (04/29/88)

Would anyone, especially Bjarne, care to enlighten me on the following
point:  7.16.3 strongly suggests, but as I read it, does not actually
legislate, that the operators operator() and operator[] must be
members, not friends.  An experiment quickly demonstrates that cfront
does, in fact, legislate this.

Take, for example, the class defined on page 181 of The Book.

class assoc {
	pair* vec
	int max;
	int free;
public:
	assoc(int);
	int& operator[](char*);
};

cfront will not let me rewrite the public part as:

public:
	assoc(int);
	friend int& operator[](assoc, char*);

My question is: what is the logical necessity for this restriction?
-- 
Herb Kanner
Apple Computer, Inc.
{idi, ios, nsc}!apple!kanner