home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!meibm31.cen.uiuc.edu!pl2440
- From: pl2440@meibm31.cen.uiuc.edu (Paul Jay Lucas)
- Subject: Re: operator overloading
- References: <1992Nov16.200145.23491@aifh.ed.ac.uk>
- Message-ID: <Bxu3DB.F7n@news.cso.uiuc.edu>
- Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
- Organization: University of Illinois at Urbana
- Date: Tue, 17 Nov 1992 00:15:09 GMT
- Lines: 26
-
- In <1992Nov16.200145.23491@aifh.ed.ac.uk> iab@cstr.ed.ac.uk writes:
-
-
- >I'm looking for some help with operator overloading. I have
- >successfully overloaded operators acting on statically declared user
- >defined classes but I would like to declare my classes dynamically and
- >still use my overloaded operators. Is this possible, i.e. to use
- >overloaded operators on pointers to a class without dereferencing
- >explicitly.
-
- *****> No; pointers are not first-class objects; operators can only be
- overloaded for class types. This shouldn't work any more than:
-
- int i = 1, j = 2, *p = &i, *q = *j;
-
- if ( p == q ) // pointer comparison only!
- // ...
-
- should, i.e., pointers to class types shouldn't get any special
- treatment over pointers to built-in types.
-
- You might consider using references whereever you can.
- --
- - Paul J. Lucas University of Illinois
- AT&T Bell Laboratories at Urbana-Champaign
- Naperville, IL pjl@cs.uiuc.edu
-