unions
c++ casting a union to one of its member types
The following seems perfectly logical to me, but isn\'t valid c++. A union cannot be implicitly cast to one of it\'s member types. Anyone kno开发者_开发百科w a good reason why not?[详细]
2023-02-12 09:43 分类:问答Union to unsigned long long int cast
I have a union as follows: typedef unsigned long GT_U32; typedef unsigned short GT_U16; typedef unsigned char GT_U8;[详细]
2023-02-11 02:57 分类:问答c++ union in multiple files
I\'m sorry this is long, but it is a little complicated to explain. We recently had to hand in for homework the following program (much simplified here):[详细]
2023-02-10 23:40 分类:问答Unions that contain a"type" member
I have a qu开发者_如何学Pythonestion about something I still don\'t understand about unions. I\'ve read about a lot of their uses and for the most part can see how they can be useful and understand th[详细]
2023-02-09 03:47 分类:问答When would anyone use a union? Is it a remnant from the C-only days?
I have learned but don\'t really get unions. Every C or C++ text I go through introduces them (sometimes in passing), but they tend to give very few practical examples of why or where to use them. Whe[详细]
2023-02-06 06:52 分类:问答Can we use pointer in union?
开发者_JAVA百科If no why? Uses of union over structure?? You can use any data type in a union, there\'s no restriction.[详细]
2023-02-06 06:32 分类:问答Union memory share in C
Edit2: Can I do polymorphism with Union? It seems to me that I can change the data structure based on my need.[详细]
2023-02-04 08:44 分类:问答Is a union of structs sharing a first element undefined behavior?
SDL_Event is a union of an unsigned 8 bit type, and many structs whose first element is an unsigned 8 bit type. The reccomended usage is to access the Uint8 element of the union to determine what type[详细]
2023-02-03 17:00 分类:问答memory alignment issues with union
Is there guarantee, that memory for this object will be properly aligned if we create object of this type in stack?[详细]
2023-01-31 08:24 分类:问答generically convert from boost::variant<T> to type
I have a typedef boost::variant<int, float, double, long, bool, std::string, boost::posix_time::ptime> variant which I use to store different types of values in a struct. Only one of the specifi[详细]
2023-01-29 15:03 分类:问答