home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 20698 < prev    next >
Encoding:
Internet Message Format  |  1993-01-05  |  1.8 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!caen!spool.mu.edu!agate!stanford.edu!apple!goofy!mumbo.apple.com!gallant.apple.com!noah.apple.com!user
  2. From: noah@apple.com (Noah Price)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Duplicate Object in Think C?
  5. Message-ID: <noah-050193094549@noah.apple.com>
  6. Date: 5 Jan 93 18:00:31 GMT
  7. References: <white.724729120@sfu.ca> <1992Dec19.002858.299@physc1.byu.edu> <d!q2saf@rpi.edu> <1993Jan5.015329.15824@reed.edu>
  8. Sender: news@gallant.apple.com
  9. Followup-To: comp.sys.mac.programmer
  10. Organization: (not the opinions of) Apple Computer, Inc.
  11. Lines: 28
  12.  
  13. In article <1993Jan5.015329.15824@reed.edu>, eric@reed.edu (eric) wrote:
  14. > Don't thinkC objects know what class they are, and can't you get this
  15. > using CObject::GetClassName?  I don't think that you have to override
  16. > this method, but then I can't recall ever having used it so . . .
  17.  
  18. Are you talking about copying objects?  I don't think you need to worry
  19. about getting the class name.
  20.  
  21. The object itself will be copied by
  22.  
  23. newObject = anyObject->Copy();
  24.  
  25. The reason that I (and Brian Hall, I think) was suggesting you might need a
  26. subclass is only if your object contains a reference to data that also
  27. wants to be duplicated.
  28.  
  29. For example, if one of your instance variables is a handle, the Copy()
  30. method will copy the handle (i.e., you'll have another pointer to the same
  31. master pointer), but NOT the data the handle references.  You have to
  32. decide for the particular situation if you just want a second handle to the
  33. same data, or if you want a new copy of the data.
  34.  
  35. noah
  36.  
  37. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. noah@apple.com                                 Macintosh Hardware Design
  39. ...!{sun,decwrl}!apple!noah   (not the opinions of) Apple Computer, Inc.
  40.