home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 15888 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  1.4 KB

  1. Path: sparky!uunet!ukma!wupost!zaphod.mps.ohio-state.edu!cs.utexas.edu!devnull!seiko.mpd.tandem.com!rjf
  2. From: rjf@seiko.mpd.tandem.com (Russell Fleming)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Operator Overload problem
  5. Message-ID: <2811@devnull.mpd.tandem.com>
  6. Date: 6 Nov 92 21:33:31 GMT
  7. References: <30001@nntp_server.ems.cdc.com>
  8. Sender: news@devnull.mpd.tandem.com
  9. Distribution: usa
  10. Lines: 28
  11.  
  12. In article <30001@nntp_server.ems.cdc.com>, jreed@ems.cdc.com (Jim Reed)
  13. writes:
  14. > Help!
  15. > I am having a problem getting my operator overload of the == 
  16. > operator to work.  If I leave my code in one .C file it works.
  17. > If I try to split it into a .C file and a .h file it doesn't.
  18.     ... much deleted ...
  19. >
  20. > int EllLowerAddress::operator==(
  21. >         EllLowerAddress address_1, EllLowerAddress address_2)
  22. >
  23.     .. much more deleted ...
  24.  
  25. Your problem is the manner in which you declared the operator== method. 
  26. Since your class definition describes operator== as a friend function,
  27. the correct way in which to declare it is:
  28.  
  29. int operator==(EllLowerAddress address_1, EllLowerAddress address_2) ...
  30.  
  31. If your class had instead declared the operator== method as a member
  32. function, your instantiation of the function would have been correct.
  33.  
  34. =================================================================
  35. Rusty Fleming, Software Consultant @ Tandem Computers Inc.
  36. email: rjf@mpd.tandem.com            Austin, Texas
  37. voice: (512) 244 - 8390              USA
  38.