[fpc-pascal] How to know if a class implements a method

Joao Morais post at joaomorais.com.br
Fri May 18 15:24:22 CEST 2007


Hello,

Any idea how I know if a class, in a class pointer, overrides a virtual 
method? Eg:

tfooclass = class of tfoo;

tfoo = class
   procedure sample; virtual;
end;

tboo1 = class(tfoo)
end;

tboo2 = class(tfoo)
   procedure sample; override;
end;

...

vfooclass := tboo1;
// vfooclass doesn't implement sample.

vfooclass := tboo2;
// vfooclass implements sample.

At this moment I know that:

1. I could cast a method pointer with tmethod if sample was a class method;

2. I could cast this same method pointer if I had an instance of vfooclass.

But is there another way beyond creating an instance?

Thanks.

--
Joao Morais



More information about the fpc-pascal mailing list