When I took a look at objects.pas in the \test\borland_\ directory (a copy below), a few questions raise to mind. 1. Does the character c have to be desposed in the destructor? If so, is char (0) a null character? 2. If there are variables (character, arrays ,strings, etc) in a function in an object, do they have to be manually deleted? If so, how would I erase each one of them? 3. Is there such a thing as a pointer to a function?
Thanks Tom
Program Objects;(* Bug fixed: objects only worked in units, not in programs. *)Type ParentPtr = ^ParentObj; ChildPtr = ^ChildObj;ParentObj = object Constructor Init; Destructor Fini; Procedure O; c: Char; (* GNU extension: mixing of fields and methods *) Procedure K; virtual;end (* ParentObj *);ChildObj = object ( ParentObj ) (* Bug fixed: no dummy variable needed here. *) Procedure O; Procedure K; virtual;end (* ChildObj *);Var MyObject: ParentPtr;Constructor ParentObj.Init;begin (* ParentObj.Init *) c:= 'K';end (* ParentObj.Init *);Destructor ParentObj.Fini;begin (* ParentObj.Fini *) c:= chr ( 0 );end (* ParentObj.Fini *);Procedure ParentObj.O;begin (* ParentObj.O *) write ( 'O' );end (* ParentObj.O *);Procedure ParentObj.K;begin (* ParentObj.K *) write ( 'y' );end (* ParentObj.K *);Procedure ChildObj.O;begin (* ChildObj.O *) write ( 'x' );end (* ChildObj.O *);Procedure ChildObj.K;begin (* ChildObj.K *) inherited K; writeln ( chr ( 8 ) + c );end (* ChildObj.K *);begin MyObject:= New ( ChildPtr, Init ); with MyObject^ do begin O; K; end (* with *); Dispose ( MyObject, Fini );end.
------------------------------------------------------ This message sent using the FirstClass SMTP/NNTP Gateway. From: Choate Rosemary Hall 333 Christian St. Wallingford, CT. 06492