What is a union?

前端 未结 5 2017
轮回少年
轮回少年 2021-02-08 09:58

Recently I am working on windows and I found that lot of data structures are defined as struct with union as member variables. Example of this would be

5条回答
  •  被撕碎了的回忆
    2021-02-08 10:34

    The union in a struct technique is generally used when you want a variant-style structure. It's generally accompanied by a type identifier, which is used to determine which item in the union to check. It's also seen in the opposite way, such as in Xlib on *NIX, where it's a union with structs, with the first member identical between all structs, defining which struct has the data you need.

提交回复
热议问题