Ada 程式設計/屬性/'Tag
外觀
X'Tag 是一個 Ada 屬性,其中 X 是任何 帶標籤型別。此屬性返回私有型別 Ada.Tags.Tag 的值,該值標識帶標籤型別。
此屬性對於檢查型別在類層次結構中的成員資格很有用。如果已知型別位於類層次結構中並且必須進行型別特定的處理,也可以使用它。
Ref : My_Tagged_Type_Reference; ...ifRef.allinMy_Tagged_Type'Classthen-- The object pointed at by Ref is in class hierarchy that is rooted at My_Tagged_Type.ifRef.all'Tag = My_Tagged_Type'Tagthen-- Object is of type My_Tagged_Type.else-- Object is of some other type in the hierarchy.endif;else-- Object is not in the class hierarchy rooted at My_Tagged_Type (it might be of a progenitor type though).endif;
