System.Classes.CountGenerations
Delphi
function CountGenerations(Ancestor, Descendent: TClass): Integer;
C++
extern DELPHI_PACKAGE int __fastcall CountGenerations(System::TClass Ancestor, System::TClass Descendent);
プロパティ
種類 | 可視性 | ソース | ユニット | 親 |
---|---|---|---|---|
function | public | System.Classes.pas System.Classes.hpp |
System.Classes | System.Classes |
説明
CountGenerations 関数は,派生クラスとその上位クラスの中間に位置するクラスの数を返します。
CountGenerations 関数を使用すると,派生クラスとその上位クラスがどのくらい近い存在であるのかがわかります。たとえば,Ancestor と Descendant が同じクラスである場合,CountGenerations は 0 を返します。Descendant が Ancestor から直接派生している場合,CountGenerations は 1 を返します。
Ancestor は,上位クラスです。
Descendant は,下位クラスです。Ancestor と同一でない,または Ancestor から派生したものではない場合,CountGenerations は -1 を返します。
ヒント: Delphi を使って Descendant が Ancestor から派生したことをチェックするには,CountGenerations を呼び出す前に Descendant が Ancestor であることを確認する is 演算子を使用します。C++ では,Descendant の静的メソッドである InheritsFrom を使用します。