Article View: comp.std.c++
Article #66Re: How do I... (regarding overloading)
From: Jim Adcock
Date: Thu, 23 Jul 1992 01:21
Date: Thu, 23 Jul 1992 01:21
22 lines
1412 bytes
1412 bytes
In article <1992Jul21.232959.13540@sunb10.cs.uiuc.edu> pjl@sparc1.cs.uiuc.edu (Paul Lucas) writes:
|*****> operator= has got nothing to do with it unless the thing that []
| returns is itself a class object (in which case operator= would
| be overloaded in _that_ class--whether operator= is overloaded
| in _this_ class is irrelevant...unless you're doing something
| non-canonical). operator[] should return a reference to the
| thing...that's it; the assignment just happens.
The overloading of operator= becomes relevant IF some committee members
succeed in changing the language such that functions cannot be invoked
on temporaries. Then the common approach of returning a SmartRef from
operator[] fails:
bitarray[100] = TRUE; // code in error if functions cannot
// be invoked on temporaries!
because this really means:
bitarray.operator[](100).operator=(TRUE);
where operator[] is returning a temporary SmartBitRef that in turn has
its operator= on it.
Technical Details
Message-ID:
<1992Jul23.012111.16784@microsoft.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!jimadReferences:
<1992Jul21.144856.583@ualr.edu> <1992Jul21.232959.13540@sunb10.cs.uiuc.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!jimad From: jimad@microsoft.com (Jim Adcock) Subject: Re: How do I... (regarding overloading) Message-ID: <1992Jul23.012111.16784@microsoft.com> Date: 23 Jul 92 01:21:11 GMT Organization: Microsoft Corporation References: <1992Jul21.144856.583@ualr.edu> <1992Jul21.232959.13540@sunb10.cs.uiuc.edu> Distribution: usa Lines: 23