Hi folks,
I just bumped into the following problem:
Assume I have several child classes derived from a parent class; in my case reading information from different file types. In particular each child class can check whether the provided file content is valid. So in order to recognize an unknown file I have to check whether a class can successfully identify it; something like:
var
file: TParentFiletype;
file := TFileType1.Create(filename);
if file.valid then Exit;
file.Free;
file := TFileType2.Create(filename);
Is there a possibility to loop over the different child classes (not instances as of yet); if I write
var
files: array[0..1] of TParentFileType = (TFileType1, TFileType2);
I get the error message
Error: typed constants of classes or interfaces are not allowed
I still assume, similar constructs/problems should be out there; however I could not find a solution.
As always: sorry to bother in case this is a trivial problem.
Thanks in advance