Skip to main content
GameDev.net gamedev.net
🔒 Locked

structure without constructor for union?

Started by DC_Tsunami Jun 4, 2003 at 5:20 PM 3 replies 500+ views
Original Post
DC_Tsunami
DC_Tsunami
I have kind of a weird question. To configure the GUI for my game, I am using an array of configuration unions. The union has a header (which is a struct), and a struct for each possible type of GUI element the structure could represent. The header would contain the type of GUI element and every different kind of structure would include the same type parameter (so it would be in the union no matter what). For those of you who have used SDL, this would be a lot like the SDL_Event union, only for a completely different purpose. When I go to compile, I get errors because every structure I include in the union has the default constructor/destructor/copy assignment operator. Is it possible to remove these from my structures?
daerid
daerid
yes, don''t declare/define them and turn them into structs instead of classes, and remove all methods.

Or, you could just turn them into pointers.
daerid@gmail.com
DC_Tsunami
DC_Tsunami
Well, I tried your suggestion, but unfortunately it didn''t work. Some of the structures contain more structures which have classes in them like STL strings, so there''s nothing I can really do about that. I guess I can just change the union to a struct with a header and a void pointer. Thanks for your help. I''ll remember this next time if a similar situation comes up.
daerid
daerid
Anything that either has a constructor, or contains a class/struct that has a constructor cannot be placed in a union.

Change ''em to pointers.
daerid@gmail.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.