constructors

Q:  Can I give a constructor any name?

A:  Constructors in C++ do have names.  It just so happens that the constructor names are all the same, and equal to the class name.  In Object Pascal, constructors do have names, and they can be different from the class name.  Furthermore, each constructor must have different name.  Typically, constructors in Delphi are called Create.  To invoke a constructor, you just call it.  For example,

var
  LB : TListBox;
begin
  LB := TListBox.Create( ... );
 

Q:  How do I invoke a named constructor?

Q:  What are the arguments of a constructor?

A:  Anything you want them to be.  Of course, if your creating a descendant class and using virtual constructors, then you don't have much choice in the parameters, they must be the same as the ancestor.

Q:  Why does the example of constructors and destructors for the class
  TShape also define TObject.Free?

A:  Yes, this is confusing.  This is only showing that when an object calls its Free method, the Destroy destructor eventually gets called.  Could use a comment in the example code <g>.

Q:  Are destructors named as well?  If so, how do I invoke them?

A:  Yes, destructors are named.  In Delphi, they are typically called Destroy.  As stated above, whenever you need to destroy an object, it is safer to call the Free method.  The rule is that if you create the object in code, then you are responsible for destroying (i.e. Freeing) it.  If you create a component using the form designer, then the Form handles destroying the components.