Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!agate!saturn!spica.ucsc.edu!daniel From: daniel@spica.ucsc.edu (Daniel Edelson) Newsgroups: comp.lang.c++ Subject: overloading -> Message-ID: <10159@saturn.ucsc.edu> Date: 3 Jan 90 02:01:06 GMT Sender: usenet@saturn.ucsc.edu Reply-To: daniel@spica.ucsc.edu (Daniel Edelson) Organization: University of California, Santa Cruz Lines: 40 I have a container class for a pointer type. Is there a way to make -> work correctly w/o explicit coercion or using (*p).member? Quick example: struct object { int a; }; typedef object * Pobject; struct container { Pobject p; container(Pobject pp) : p(pp) { } operator Pobject() { return p; } object & operator * () { return *p; } }; main() { object o; container p = &o; (*p).a // works but unnatural style Pobject(p)->a // works but explicit coercion is ugly p->a; // doesn't work } I would the user-defined conversion to take place before the -> operator is applied, but that doesn't appear to be what the language specifies. I've tried 3 distinct compilers (cfront 2.0, oregon, g++) and they all behave the same. Help is greatly appreciated, Daniel Edelson daniel@cis.ucsc.edu