Newsgroups: comp.lang.c++ Path: utzoo!utgpu!watserv1!watmath!watmsg!gjditchfield From: gjditchfield@watmsg.uwaterloo.ca (Glen Ditchfield) Subject: Re: overloading operator . and -> Message-ID: <1991Mar26.155836.14539@watmath.waterloo.edu> Sender: daemon@watmath.waterloo.edu (0000-Admin(0000)) Organization: University of Waterloo References: <14.UUL1.3#8618@softrue.UUCP> <4608@lupine.NCD.COM> <1991Mar25.154013.4044@world.std.com> Date: Tue, 26 Mar 1991 15:58:36 GMT Lines: 14 In article <1991Mar25.154013.4044@world.std.com> wmm@world.std.com (William M Miller) writes: >For me, allowing operator->() leads to a more consistent language while >still permitting me the syntactic convenience of writing ptr->member instead >of (*ptr).member. I agree that the expansion of "ptr->member" to >"(ptr.operator->())->member" is a bit strange, but I think the alternatives >(implicit invocation of operator*() for "->" or not allowing the ptr->member >notation at all) are worse. There was another alternative. Don't treat "->" and "." as infix operators; treat "->foo" and ".foo" as postfix operators. That's how the ANSI C standard defines them. struct C { int operator ->foo(); }; This wouldn't have helped programmers who want to define smart pointers.