Archived

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

This topic is 5277 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
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
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
It's a shame, C#'s method of forcing you to append the enum name to the front is nice.

I'll get on the VC++ newsgroups and ask about it later on.

Edit: also, I've noticed you can't even forward declare enums. I can't see why though, enums are just converted to ints.

[edited by - antareus on July 7, 2003 9:44:10 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by Thunder_Hawk

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

}




jesus christ, that is the most hack-a-rific thing I''ve seen in a while.

Share this post


Link to post
Share on other sites
quote:
Original post by Thunder_Hawk

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

}



er.... which would preprocess to:


namespace Status::X {
enum X {Fail, Pass};
}


No points for guessing whether that compiles.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites