This is probably a simple question, but i would like to know how to ensure a class' constructor is called.
If i have the following code:
type TMyObject = class(TObject)
public
constructor Create;override;
end;
implementation
constructor TMyObject.Create;override;
begin
inherited;
//do other instantiation
end;
Delphi does not allow this - 'Cannot override a static method'.
What i would like to do is ensure that the object is created using my custom Create constructor AND prohibiting calling the ancestors Create constructor.
My current solution to the problem is to define a uniquely signatured Create constructor like so:
constructor Create(aName : String);overload;
but the programmer could potentially call the ancestors Create() method.
TObjectList
withOwnsObject := True
) than creating an object with an arbitrary class. – Gerry Coll