home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12348 < prev    next >
Encoding:
Internet Message Format  |  1992-08-14  |  1.7 KB

  1. Path: sparky!uunet!ogicse!uwm.edu!cs.utexas.edu!sun-barr!decwrl!pa.dec.com!brister
  2. From: brister@decwrl.dec.com (James Brister)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Reference counting for vectors, (Tony Hansen's book).
  5. Message-ID: <BRISTER.92Aug14110706@tirade.decwrl.dec.com>
  6. Date: 14 Aug 92 18:07:06 GMT
  7. Article-I.D.: tirade.BRISTER.92Aug14110706
  8. References: <1992Aug14.164719.9719@wuecl.wustl.edu>
  9. Sender: news@PA.dec.com (News)
  10. Organization: DEC Western Software Lab
  11. Lines: 26
  12. In-Reply-To: abed@venus.wustl.edu's message of Fri, 14 Aug 1992 16:47:19 GMT
  13.  
  14. On Fri, 14 Aug 1992 16:47:19 GMT, abed@venus.wustl.edu (Abed M. Hammoud) said:
  15. > I was trying to implement the vector class using the method suggested
  16. > by tony Hansen. i.e reference counting. the following code is taken
  17. > from Hansen's book (C++ Answer book). There is some thing that doesn't
  18. > seems correct.
  19.  
  20. What's not correct? The fact that modifying one variable causes the other
  21. to change? If that's not what you want, then this isn't for you, but in the
  22. case where you're making multiple copies of the array (as paramaters to a
  23. function, for example), then this scheme is great.
  24.  
  25. I do remember seeing an article in a magazine a while back about COW (copy
  26. on write), where the new array (i.e. 'B' here)
  27.  
  28. >     vector B = A; 
  29.  
  30. would release the referrence and make a duplicate of the real data if any
  31. data was going to be modified. Unfortuantely I can't remember the details
  32. right now of how it worked, but it didn't seem too tough to do.
  33.  
  34. (If anyone can refresh my memory that would be good.)
  35.  
  36. James
  37. --
  38. James Brister                                           brister@wsl.pa.dec.com
  39. DEC Western Software Lab., Palo Alto, CA                        decwrl!brister
  40.