Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari!uflorida!ziggy!usfvax2!tct!chip From: chip@tct.uucp (Chip Salzenberg) Newsgroups: comp.lang.c++ Subject: Re: operator []: ref vs value Message-ID: <25E5841D.5B4A@tct.uucp> Date: 23 Feb 90 18:42:36 GMT References: <5216@brazos.Rice.edu> Organization: ComDev/TCT, Sarasota, FL Lines: 17 According to dougm@zamenhof.rice.edu (Doug Moore): >Unfortunately, I want one behavior when the pseudo-array access occurs >as an rvalue and another when it appears as an lvalue. Can I get what >I want? You almost had it. Define a reference_to_missing_array_element type, and have operator[] return an object of that type. Then define: reference_to_missing_array_element::operator float() return 0.0 reference_to_missing_array_element::operator = (float) create the missing array element and assign to it No sweat.