RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Classes.CountGenerations Function

Returns the number of intermediate classes between a derived class and its ancestor.

Pascal
function CountGenerations(Ancestor: TClass; Descendent: TClass): Integer;
C++
int CountGenerations(TClass Ancestor, TClass Descendent);

Classes

Use CountGenerations to determine how close a derived class is to one of its ancestors. For example, if Ancestor and Descendant are the same class, CountGenerations returns 0. If Descendant is derived directly from Ancestor, CountGenerations returns 1. 

Ancestor is the ancestor class. 

Descendant is the descendant class. If it is not the same as Ancestor or does not derive from Ancestor, CountGenerations returns –1.

Tip: To check that Descendant derives from Ancestor using Delphi, use the is operator to check that Descendant is Ancestor before calling CountGenerations. In C++, use the static InheritsFrom method of Descendant.
 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!