System.Classes.CountGenerations

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function CountGenerations(Ancestor, Descendent: TClass): Integer;

C++

extern DELPHI_PACKAGE int __fastcall CountGenerations(System::TClass Ancestor, System::TClass Descendent);

Properties

Type Visibility Source Unit Parent
function public
System.Classes.pas
System.Classes.hpp
System.Classes System.Classes

Description

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.