Unit unit1; interfaceuses windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; Procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} type tmyrecord = record {definition structure} D: tdate; end; tmyclass = Class {definition class; although this class has no practical significance, it is a class} D: tdate; end; Procedure tform1.button1click (Sender: tobjec T); var myrec: tmyrecord; {declare a structure variable} mycls: tmyclass; {declare a class variable, that is, object} begin {use structure} myrec. d: = now; showmessage (datetostr (myrec. d); {} showmessage (inttostr (sizeof (myrec); {8; the size of myrec structure is 8} {use class} mycls: = tmyclass. create; {need to be created manually first, because the class needs to be instantiated as an object before it can be used} mycls. d: = now; {2008-1-11} showmessage (datetostr (mycls. d); showmessage (inttostr (sizeof (mycls); {4; how can it be 4? Because the mycls object is just a pointer !} Mycls. free; {release after use} {conclusion: the structure (or record) and class are both custom types. The structure is directly used and the memory is automatically managed. The class is just a model, you need to create (create) an object based on the model (that is, the class) to use. You need to manually release the memory after use. (The memory usage rules should be: the structure of automatic release and manual release is stored in a different way than that of the object (class instance) in the memory. The object is just a pointer. Compared with the structure, class has this more powerful function !} End; end.