Path: utzoo!mnetor!uunet!husc6!mit-eddie!ll-xn!ames!oliveb!pyramid!prls!philabs!pwa-b!mmintl!franka From: franka@mmintl.UUCP (Frank Adams) Newsgroups: comp.lang.c++ Subject: Re: Why doesn't c++ allow overloading member operators? Message-ID: <2783@mmintl.UUCP> Date: 21 Mar 88 21:36:01 GMT References: <11778@sri-spam.istc.sri.com> <8180005@eecs.nwu.edu> Reply-To: franka@mmintl.UUCP (Frank Adams) Organization: Ashton-Tate Corporation, East Hartford Development Center Lines: 23 In article <8180005@eecs.nwu.edu> morrison@eecs.nwu.edu (Vance Morrison) writes: > The question is "why doen't c++ allow you to overload the "." operator. Actually, the original poster was regarding ".member" as the operator, not just the ".". > The real reason you probably want overloading is to allow "controled >access" to instance variables. What would meet this need without overloading >the "." is for c++ to REDEFINE the "." operator for the class EXAMPLE so > > example.member means example.member() The problem is that there are, more or less, two operations associated with members: access and update. The above is useless if I want to want to use statements like: "example.member = foo;". (It is *not* sufficient to define the member() function as returning a reference (such as "int &member()"), since in general, one wants to *do* something for the access/assignment.) -- Frank Adams ihnp4!philabs!pwa-b!mmintl!franka Ashton-Tate 52 Oakland Ave North E. Hartford, CT 06108