home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19742 < prev    next >
Encoding:
Text File  |  1993-01-22  |  1.1 KB  |  50 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!ux1.cso.uiuc.edu!cs.uiuc.edu!sparc0b!pjl
  3. From: pjl@cs.uiuc.edu (Paul Lucas)
  4. Subject: Re: Friend ..Overload Assignment opertr ..
  5. Message-ID: <C19838.JM3@cs.uiuc.edu>
  6. Sender: news@cs.uiuc.edu
  7. Organization: University of Illinois at Urbana-Champaign
  8. References: <1993Jan22.075317.21062@usl.edu>
  9. Date: Fri, 22 Jan 1993 12:01:56 GMT
  10. Lines: 38
  11.  
  12. In <1993Jan22.075317.21062@usl.edu> rks9954@usl.edu (Srinivasa Rao K) writes:
  13.  
  14.  
  15.  
  16.  
  17. > Hi C++ masters,
  18.  
  19. >       I have small question ...
  20.  
  21. >       I am writing a "string"  class which i should be able
  22. >       to use like
  23.  
  24.  
  25. >       string str1;
  26.  
  27. >       str1 = "Hello world" ;
  28.  
  29.  
  30.  
  31. >       But We canot use a friend to overload the assignment oprator.
  32.  
  33. >      So finally  I had to convince myself to use something like
  34.  
  35.  
  36. >       str1 <= "Hello world"
  37.  
  38.  
  39. >       which works.
  40.  
  41. >      Is there any way to do the first method ....
  42.  
  43.     No.  operator=() must be a member.  Period.  Everybody defines it
  44.     this way and has no problem.  Whats wrong with it being a member?
  45. -- 
  46.     - Paul J. Lucas
  47.       AT&T Bell Laboratories
  48.       Naperville, IL
  49.