Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!herald.usask.ca!alberta!cpsc.ucalgary.ca!news From: gintera@cs-sun-fsa.cpsc.ucalgary.ca (Andrew Ginter) Newsgroups: comp.lang.c++ Subject: Overloaded a->b == (*a).b ? Message-ID: <1991Mar25.225725.8625@cpsc.ucalgary.ca> Date: 25 Mar 91 22:57:25 GMT Organization: U. of Calgary Computer Science Lines: 26 Originator: gintera@fsd Nntp-Posting-Host: fsd In section 13.4, ARM suggests: "For example, if more than one of the operators ->, *, and [] are defined for a class V, one would expect v->m, (*v).m, and v[-].m to have identical values for all objects v of class V." At the same time, we find in section 13.4.6: "An expression x->m is interpreted as (x.operator->())->m for a class object x. It follows that operator->() must either return a pointer to a class or an object of or a reference to a class for which operator->() is defined." If operator-> returns a reference to a class for which operator -> is defined, the processes of resolving the overloaded operator -> continues recursively until something other than an object of or a reference to a class with an operator-> is returned. This same is NOT true of an overloaded operator*(). It may therefore be non-trivial for a programmer to maintain the a->b == (*a).b equivalence. Have I missed something here? Andrew Ginter, 403-220-6320, gintera@cpsc.ucalgary.ca