Jump to content
  • Advertisement

Archived

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

Roof Top Pew Wee

Question about structs

This topic is 6062 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Guest Anonymous Poster
Look up the behavior of named and unnamed structs.

Share this post


Link to post
Share on other sites
create a struct like this
    
struct Globlas
{
// stuff

};


there has to be the name before, but the one after is optional

Edited by - ncsu121978 on October 18, 2001 4:58:09 PM

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!