[fpc-pascal] "class of" variables typecasts

Daniel Gaspary dgaspary at gmail.com
Thu Aug 22 17:06:58 CEST 2013


> learn about class references (i.e. "class of" declarations) and
constructors.

Since "class of" was on topic of other thread...

Is possible(How?) to perform typecasts like:

AClassType(obj); ??

Example:

type
    TClass1 = class(TObject);
    TClass2 = class(TClass1);
    TClass3 = class(TClass1);
    TClassType = class of TClass1;
procedure DoSomething(AClassType: TClassType; obj: TClass1);
begin
        AClassType(obj).RunAMethod(...); //Wrong, it is typecasting to
"class of", I believe
end;

The "obj as AClassType" kind I know it works.



More information about the fpc-pascal mailing list