[fpc-pascal] how to determine if a class has descendant registered within the current program

Michael Van Canneyt michael at freepascal.org
Wed Mar 8 11:55:57 CET 2017

On Wed, 8 Mar 2017, Dennis wrote:

> I have a many classes, one inherits from another one, in an ancestor 
> method, I want to test whether the calling class is a childless class.
> e.g.
> class function TAncestor.GetCaption : String; //virtual
> begin
>     if HasChild then
>       result := 'something'
>   else
>     result := 'something else';
> end;
> where HasChild is a boolean class function that tells me whether the 
> current calling class has children defined or now.
> Is that possible?

Currently not, but I think that Sven Barth will implement something 
for the new RTTI which will make this possible in the future.


More information about the fpc-pascal mailing list