home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 20071 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.0 KB  |  34 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!caen!destroyer!cs.ubc.ca!newsserver.sfu.ca!sfu.ca!white
  3. From: white@fraser.sfu.ca (Steve White)
  4. Subject: Duplicate Object in Think C?
  5. Message-ID: <white.724729120@sfu.ca>
  6. Sender: news@sfu.ca
  7. Organization: Simon Fraser University, Burnaby, B.C., Canada
  8. Date: Sat, 19 Dec 1992 01:38:40 GMT
  9. Lines: 23
  10.  
  11. How do you duplicate an object without knowing its class?  We would like
  12. to write something like
  13.  
  14. r = duplicate( p );
  15.  
  16. to get an object r of the same class and attributes as p.
  17.  
  18. We tried to write such a thing of our own using some combination of
  19. sizeof, memmove, and Bless, but ran into a couple of problems.
  20.  
  21. The Think C Class Library Manual claims that 
  22.  
  23. sizeof( class_name )
  24.  
  25. will return the size of an object in a class.  We get "illegal use of
  26. class type" when we try to compile, e.g., 
  27.  
  28. sizeof( Window )
  29.  
  30. Is there some setting we're missing, or what?  We're running v. 5.0.4.
  31.  
  32. Is there some standard way of achieving the duplication of an object?
  33.  
  34.