是否可以在Ada中扩展Enum类型?如果我有例如:
type ABC_Type is (A, B, C);
Run Code Online (Sandbox Code Playgroud)
现在我想要新类型ABCDE_Type,它将包含ABC_Type所有的所有内容以及(D,E).有没有办法做到这一点?
不,您不能在Ada中扩展Enum类型,您只能创建覆盖原始类型的子集的派生/子类型.
你必须反过来这样做:
type ABCDE_Type is (A, B, C, D, E);
type ABC_Type is new ABCDE_Type range A .. C;
-- or
subtype ABC_Type is ABCDE_Type range A .. C;
Run Code Online (Sandbox Code Playgroud)