home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / pascal / 4480 < prev    next >
Encoding:
Text File  |  1992-07-21  |  1.2 KB  |  35 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!cs.utexas.edu!torn!watserv1!watdragon.waterloo.edu!watstat.waterloo.edu!dmurdoch
  3. From: dmurdoch@watstat.waterloo.edu (Duncan Murdoch)
  4. Subject: Re: Constants in an Object
  5. Message-ID: <BrqM02.BtG@watdragon.waterloo.edu>
  6. Sender: news@watdragon.waterloo.edu (USENET News System)
  7. Reply-To: dmurdoch@mast.queensu.ca
  8. Organization: University of Waterloo
  9. References: <1992Jul19.073015.1199@ecst.csuchico.edu> <phfrom.183@nyx.uni-konstanz.de>
  10. Date: Tue, 21 Jul 1992 11:45:37 GMT
  11. Lines: 22
  12.  
  13. In article <phfrom.183@nyx.uni-konstanz.de> phfrom@nyx.uni-konstanz.de (Hartmut Frommert) writes:
  14. >
  15. >What I didn't try up to now is
  16. >
  17. >const
  18. >  MyObject: TMyObject = (345);
  19. >
  20. >or thelike. I assume this failes because no memory is reserved for MyObject;
  21. >this is done by the constructor call. 
  22.  
  23. You can have object constants, but the value has to be declared like a 
  24. record constant:
  25.  
  26.   const
  27.     MyObject: TMyObject = (Myfield: 345);
  28.  
  29. The constructor call doesn't allocate memory, it fills in the VMT field.
  30. The compiler does that for you in a constant object, so no constructor
  31. call is needed.  This is discussed in Chapter 5 of the Programmer's Guide.
  32.  
  33. Duncan Murdoch
  34. dmurdoch@mast.queensu.ca
  35.