LacaK via fpc-pascal
2021-04-29 06:51:47 UTC
Hi *,
consider the following example
T1 = class
class procedure CP1;
procedure P1; virtual;
end;
T2 = class(T1)
class procedure CP1;
end;
procedure T1.P1;
begin
CP1; // here is called allways T1.CP1, right?
// if I want call T2.CP1 then class procedure CP1 must be also
virtual, right?
// so Self.CP1 does not take runtime type but is staticaly resolved
at compile time to T1.CP1 ?
end;
var
c1: T1;
begin
c1:=T2.Create;
c1.P1; // here is called T2.P1 - runtime class type
end.
Thanks
Btw If I need for various class descendants define various class
constants, it is possible only by using class functions (getters), where
descendant class getter hides parents getter?
-Laco.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.o
consider the following example
T1 = class
class procedure CP1;
procedure P1; virtual;
end;
T2 = class(T1)
class procedure CP1;
end;
procedure T1.P1;
begin
CP1; // here is called allways T1.CP1, right?
// if I want call T2.CP1 then class procedure CP1 must be also
virtual, right?
// so Self.CP1 does not take runtime type but is staticaly resolved
at compile time to T1.CP1 ?
end;
var
c1: T1;
begin
c1:=T2.Create;
c1.P1; // here is called T2.P1 - runtime class type
end.
Thanks
Btw If I need for various class descendants define various class
constants, it is possible only by using class functions (getters), where
descendant class getter hides parents getter?
-Laco.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.o