home *** CD-ROM | disk | FTP | other *** search
- 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
- From: noah@apple.com (Noah Price)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Duplicate Object in Think C?
- Message-ID: <noah-050193094549@noah.apple.com>
- Date: 5 Jan 93 18:00:31 GMT
- References: <white.724729120@sfu.ca> <1992Dec19.002858.299@physc1.byu.edu> <d!q2saf@rpi.edu> <1993Jan5.015329.15824@reed.edu>
- Sender: news@gallant.apple.com
- Followup-To: comp.sys.mac.programmer
- Organization: (not the opinions of) Apple Computer, Inc.
- Lines: 28
-
- In article <1993Jan5.015329.15824@reed.edu>, eric@reed.edu (eric) wrote:
- >
- > Don't thinkC objects know what class they are, and can't you get this
- > using CObject::GetClassName? I don't think that you have to override
- > this method, but then I can't recall ever having used it so . . .
-
- Are you talking about copying objects? I don't think you need to worry
- about getting the class name.
-
- The object itself will be copied by
-
- newObject = anyObject->Copy();
-
- The reason that I (and Brian Hall, I think) was suggesting you might need a
- subclass is only if your object contains a reference to data that also
- wants to be duplicated.
-
- For example, if one of your instance variables is a handle, the Copy()
- method will copy the handle (i.e., you'll have another pointer to the same
- master pointer), but NOT the data the handle references. You have to
- decide for the particular situation if you just want a second handle to the
- same data, or if you want a new copy of the data.
-
- noah
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- noah@apple.com Macintosh Hardware Design
- ...!{sun,decwrl}!apple!noah (not the opinions of) Apple Computer, Inc.
-