Jump to content
  • Advertisement

Archived

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

TheJakub

enums

This topic is 5491 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

enum Status{ Fail = 0, Pass = 1 }; ... Status s; s = Status:: Pass; ... Can someone tell me why this isnt working in VC. I have made it work in the past, I'm just confused when it returns an error saying that Pass is not a member of Status. ( disregard the space after Status:: )

Share this post


Link to post
Share on other sites
Advertisement
Thanks for the help. Whenever something in c++ doesnt feel like working, I just want to start throwing stuff. This time my monitor has been saved. ;-)

Share this post


Link to post
Share on other sites
quote:

Whenever something in c++ doesnt feel like working, I just want to start throwing stuff.



Yeah I know the feeling. I've gotten over it by realising that its almost always oneself that's at fault and getting stressed out is a very ineffective way of solving such problems. Also just imagine what a fit babe would think if she was watching you thrash about like a baby.

[edited by - barn door on July 6, 2003 6:38:58 PM]

Share this post


Link to post
Share on other sites
Actually is there a way so that you can use Status:: without actually putting it as a static member in a structure?

Share this post


Link to post
Share on other sites
Unfortunately, not with Visual Studio (event 2003). However, it is covered by the standard.

Share this post


Link to post
Share on other sites
quote:
Original post by antareus
Actually is there a way so that you can use Status:: without actually putting it as a static member in a structure?


Hmm...

#define Status Status::X
namespace Status {
enum X {Fail, Pass}; // First one starts out as zero (I believe that's guaranteed)

}

I think that should work.

[EDIT] Whoops, I got the enums backwards
[EDIT2] Crap, you lose the declaration capability.
[EDIT3] I think I figured it out...maybe
[EDIT4] There I made a proper hack out of it

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________



[edited by - Thunder_Hawk on July 6, 2003 10:28:09 PM]

[edited by - Thunder_Hawk on July 6, 2003 10:38:19 PM]

Share this post


Link to post
Share on other sites
Actually, I have done it before. In my code it seems that when the enum is inside of a class, doing "Class::Status::OK" actually works. But then when I put the enum into a namespace or just global and not encapsulated anywhere I get the "not a member of" error. Very strange if you ask me, and it simply doesnt make sense. I guess its one of those quirks you get with VC. You kinda learn to live with it and try out a different way to do things. Which really sucks sometimes:-P

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!