Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: C++ Struct

  1. #1
    Regular Coder
    Join Date
    Mar 2004
    Location
    Australia
    Posts
    217
    Thanks
    0
    Thanked 1 Time in 1 Post

    C++ Struct

    Ok i now am just curious. I have a struct that adds certain attributes to an object. i was wodering if i could set them for 2 or more.

    Code:
    struct
    {
    	bool bVisible;
    	GF1::Sprite* pSprite;
    }  m_block[MAX_BLOCKS];
    
    
    struct
    {
    	bool bVisible;
    	GF1::Sprite* pSprite;
    }  m_block[MAX_BLOCKS], m_menuBg; <----- such as that.
    just wondering if its possible, would save me creating many structures.

    edit: i think i answered my own question. feedback would be nice
    Last edited by Serex; 11-03-2004 at 06:50 AM.

  • #2
    New Coder
    Join Date
    Nov 2004
    Location
    Netherlands
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm not sure if you're talking about arrays of structs, or just multiple different structs. If it's the latter, you could make a typdef struct then just declare it multiple times afterwards. Something like:
    Code:
    typedef struct
    {
    	bool bVisible;
    	GF1::Sprite* pSprite;
    }  M_MENUBG;
    
    M_MENUBG menu1;
    M_MENUBG menu2;
    //etc...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •