In the Delphi and C++Builder environments, an "object" is a "pointer." When you execute the constructor, by means of
New, three things happen:
- A block of memory is allocated and set entirely to zero. This will include space for the object description record (positioned at a negative offset from the returned pointer), the object's private and public variables, and the method-table pointers.
- The object's constructor(s) are called to initialize the new object.
- A pointer to the memory-block is returned as the return-value of New.
You can use this return-value in a number of ways. One very convenient way to store it is to put it in a
TList, which you'll see that the VCL itself does in many places. (For example, a
TForm contains a list of all the controls that exist on it.) You can assign it to a local variable. By any of these means you can then invoke the object's properties and methods.
I think you'll accomplish what you want by using a
TList.
Bear in mind: There is no "reference counting" for objects and no automatic cleanup: what you
New, you must also eventually
Free. Before you delete the
TList you'll probably need to iterate through it and Free everything that it points to.