Purpose of Unions in C and C++

后端 未结 16 2101
予麋鹿
予麋鹿 2020-11-22 06:55

I have used unions earlier comfortably; today I was alarmed when I read this post and came to know that this code

union ARGB
{
    uint32_t colour;

    str         


        
16条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 07:25

    For one more example of the actual use of unions, the CORBA framework serializes objects using the tagged union approach. All user-defined classes are members of one (huge) union, and an integer identifier tells the demarshaller how to interpret the union.

提交回复
热议问题