Archived

This topic is now archived and is closed to further replies.

Roof Top Pew Wee

Question about structs

Recommended Posts

I had a problem using a struct, but figured out the answer by accident. Now I''m wondering why what I''ve done works. Here''s the problem. // Globals.h #include "legendsGUI.h" // this is a header defining // some GUI classes struct { // lots of DirectX stuff here button myButton; // button class defined in legendsGUI.h } G; // end of Globals.h When I compile this in my program, I get an error if the button myButton is in there. When I take it out, the program has no error. I''ve figured that if I also put a name after the struct definition (if I have struct globals {}G; instead of just struct {}G; ) I no longer get the error. Can someone clarify why giving the struct a name rather than just instantiating it at the bottom fixes this error? Thanks --Vic--

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Are you sure the adding or removing of that button variable causes the error? I mean, it´s just a variable like all the directx variables.

If you''re sure that it is causing the problem, maybe there´s something conflicting in the constructor of the button class.

Nick

Share this post


Link to post
Share on other sites
Are you sure the adding or removing of that button variable causes the error? I mean, it´s just a variable like all the directx variables.

If you''re sure that it is causing the problem, maybe there´s something conflicting in the constructor of the button class.

Nick

Share this post


Link to post
Share on other sites
nickm: Yes, I am sure it is the button. In fact, anything out of the "legendsGUI.h" file. Interesting thing. If I remove the contstructors out of the button (or any class I am going to create in the G struct) it works fine. However, these are classes which need constructors.

ncsu: I have solved the problem. I now that if I make a struct like that, it solves it. I am just wondering why.

Share this post


Link to post
Share on other sites