TFoo = class
public
constructor Create; virtual;
end;
TBar = class(TFoo);
public
constructor Create; override;
end;
TFooClass = class of TFoo; //declares a class reference type
...
var
fc: TFooClass;
afoo: TFoo;
begin
fc := TFoo;
afoo := fc.Create; // returns a TFoo
...
fc := TBar;
afoo := fc.Create; // returns a TBar
{contrived example - we could just call TFoo.Create or TBar.Create in these cases}
end;
There must be similar features in other typed languages surely?