gpt4 book ai didi

enums - 在 Ada 中扩展枚举

转载 作者:行者123 更新时间:2023-12-04 14:31:54 27 4
gpt4 key购买 nike

是否可以在 Ada 中扩展 Enum 类型?
如果我有例如:

type ABC_Type is (A, B, C);

现在我想要新类型 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;

关于enums - 在 Ada 中扩展枚举,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11651828/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com