gpt4 book ai didi

c - union 内的 union

转载 作者:行者123 更新时间:2023-11-30 16:33:59 25 4
gpt4 key购买 nike

在 C 语言中,是否可以在另一个 union 体中定义一个 union 体?如果不是,为什么不可能?或者如果可以,可以在哪里使用?

最佳答案

假设您要定义:

union myun {
int x;
sometype y;
};

其中 sometype 是由您正在使用的库定义的 typedef。如果库碰巧将其实现为 union 类型,那么这将是 union 中的 union ,并且这是有意义的,因为您不能(从良好的设计角度来看)违反库类型的封装。

关于c - union 内的 union ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49445782/

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