function CountGenerations(Ancestor, Descendent: TClass): Integer;
extern PACKAGE int __fastcall CountGenerations(System::TClass Ancestor, System::TClass Descendent);
Returns the number of intermediate classes between a derived class and its ancestor.
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.