Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-08

"class of" variables typecasts

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Daniel Gaspary
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.

Reply by email