ha ha ha .....
NND!
=====================
A constructor can be called using a variable of a class-reference type.
This allows construction of objects whose type isn? known at compile time.
For example,
type TControlClass = class of TControl;
function CreateControl(ControlClass: TControlClass;
const ControlName: string; X, Y, W, H: Integer): TControl;
begin
Result := ControlClass.Create(MainForm);
with Result do
begin
Parent := MainForm;
Name := ControlName;
SetBounds(X, Y, W, H);
Visible := True;
end;
end;
The CreateControl function requires a class-reference parameter to
tell it what kind of control to create. It uses this parameter to
call the class? constructor.
Because class-type identifiers denote class-reference values,
a call to CreateControl can specify the identifier of the class
to create an instance of. For example,
CreateControl(TEdit, 'Edit1', 10, 10, 100, 20);
Constructors called using class references are usually virtual.
The constructor implementation activated by the call depends
on the runtime type of the class reference.