工会内部的工会 [英] Unions within unions

查看:119
本文介绍了工会内部的工会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C,是有可能的另外一个联盟中定义一个工会?如果没有,为什么不可能?或者,如果有,在哪里可以应用?

In C, is it possible to define a union within another union? If no, why is it not possible? Or if yes, where can it be used?

推荐答案

假设你要定义:

union myun {
  int x;
  sometype y;
};

其中, sometype。这时候的typedef 由您使用的是库中定义。如果库恰巧实现它作为一个联合类型,那么这将是一个工会内的工会,这是有意义的,因为你不能(从一个好的设计的角度来看)违反了图书馆的类型的封装。

where sometype is a typedef defined by a library you're using. If the library happened to implement it as a union type, then this would be a union within a union, and it would make sense because you can't (from a good design standpoint) violate the encapsulation of the library's type.

这篇关于工会内部的工会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆