home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19959 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.4 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!hal.com!olivea!spool.mu.edu!agate!doc.ic.ac.uk!warwick!uknet!axion!planet.bt.co.uk!njs
  2. From: njs@planet.bt.co.uk (Non NIS Account)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Friend ..Overload Assignment opertr ..
  5. Message-ID: <1993Jan26.151154.19244@planet.bt.co.uk>
  6. Date: 26 Jan 93 15:11:54 GMT
  7. References: <1993Jan22.075317.21062@usl.edu>
  8. Sender: news@planet.bt.co.uk
  9. Organization: DNM42, BT Labs, Martlesham Heath, Ipswich, UK.
  10. Lines: 42
  11. Originator: njs@andromeda
  12.  
  13.  
  14. In article <1993Jan22.075317.21062@usl.edu>, rks9954@usl.edu (Srinivasa Rao K) writes:
  15. |> 
  16. |>  
  17. |> 
  18. |> 
  19. |>  Hi C++ masters,
  20. |> 
  21. |>        I have small question ...
  22. |> 
  23. |>        I am writing a "string"  class which i should be able
  24. |>        to use like
  25. |> 
  26. |> 
  27. |>        string str1;
  28. |> 
  29. |>        str1 = "Hello world" ;
  30. |> 
  31. |> 
  32. |> 
  33. |>        But We canot use a friend to overload the assignment oprator.
  34.  
  35. Why should you want to use a friend to redefine the assignment operator?  If you are designing a class you can also include a definition for the `=` operator to give it the semantics you want.  See 13.4 ARM.
  36.  
  37. |> 
  38. |>       So finally  I had to convince myself to use something like
  39. |> 
  40. |> 
  41. |>        str1 <= "Hello world"
  42. |> 
  43. |> 
  44. |>        which works.
  45. |> 
  46. |>       Is there any way to do the first method ....
  47. |> 
  48. |>       
  49. |>       Thanks for those who spend time reading this ....
  50. |> 
  51. |> 
  52. |> 
  53. |> 
  54. |> Rao.
  55.