On Thu, 29 Apr 2021, LacaK via fpc-pascal wrote:


Dňa 29.4.2021 o 9:26 Michael Van Canneyt via fpc-pascal napísal(a):


On Thu, 29 Apr 2021, LacaK via fpc-pascal wrote:

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?

Yes

  // so Self.CP1 does not take runtime type but is staticaly resolved at compile time to T1.CP1 ?

Yes.

This is bit counter-intuitive for me:

For me not, it's perfectly logical.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to