home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ukma!wupost!zaphod.mps.ohio-state.edu!cs.utexas.edu!devnull!seiko.mpd.tandem.com!rjf
- From: rjf@seiko.mpd.tandem.com (Russell Fleming)
- Newsgroups: comp.lang.c++
- Subject: Re: Operator Overload problem
- Message-ID: <2811@devnull.mpd.tandem.com>
- Date: 6 Nov 92 21:33:31 GMT
- References: <30001@nntp_server.ems.cdc.com>
- Sender: news@devnull.mpd.tandem.com
- Distribution: usa
- Lines: 28
-
- In article <30001@nntp_server.ems.cdc.com>, jreed@ems.cdc.com (Jim Reed)
- writes:
- > Help!
- >
- > I am having a problem getting my operator overload of the ==
- > operator to work. If I leave my code in one .C file it works.
- > If I try to split it into a .C file and a .h file it doesn't.
- >
- ... much deleted ...
- >
- > int EllLowerAddress::operator==(
- > EllLowerAddress address_1, EllLowerAddress address_2)
- >
- .. much more deleted ...
-
- Your problem is the manner in which you declared the operator== method.
- Since your class definition describes operator== as a friend function,
- the correct way in which to declare it is:
-
- int operator==(EllLowerAddress address_1, EllLowerAddress address_2) ...
-
- If your class had instead declared the operator== method as a member
- function, your instantiation of the function would have been correct.
-
- =================================================================
- Rusty Fleming, Software Consultant @ Tandem Computers Inc.
- email: rjf@mpd.tandem.com Austin, Texas
- voice: (512) 244 - 8390 USA
-