Well it might not have been a waste, that one guy above might have learned what enumeration is
hopefully.
Enums are pissing me off!
a2k:
As a hint to avoid this in the future, here''s what I do with my enums:
1) Don''t make any of them global. I like having an enum be part of the public interface of a class. That way, I must refer to the values "class::enum_val", which communicates the scope & purpose of the enum better. This is how a lot of the standard C++ library is done (i.e. "ios::write").
2) Always preface my enum values with the class name. I keep them caps, too (like some people do for #defines), but that''s just a style thing. So if I have an enum called char_traits, I do it like this:
enum char_traits { CT_STRENGTH, CT_DEXTERITY, CT_INTELLIGENCE };
You get the picture. If you adopt some or all of these styles, it''ll help you avoid this problem in the future.
As a hint to avoid this in the future, here''s what I do with my enums:
1) Don''t make any of them global. I like having an enum be part of the public interface of a class. That way, I must refer to the values "class::enum_val", which communicates the scope & purpose of the enum better. This is how a lot of the standard C++ library is done (i.e. "ios::write").
2) Always preface my enum values with the class name. I keep them caps, too (like some people do for #defines), but that''s just a style thing. So if I have an enum called char_traits, I do it like this:
enum char_traits { CT_STRENGTH, CT_DEXTERITY, CT_INTELLIGENCE };
You get the picture. If you adopt some or all of these styles, it''ll help you avoid this problem in the future.
hey, thanks for the tippers, stoffel.
actually, i had them originally embedded in my classes, but got really frustrating to type player.playerstate = player.alive<br><br>i''d rather have player.playerstate = alive<br><br>but, the caps idea is good, especially since it''s fairly standard<br>so, i''m gonna use<br><br>player.PlayerState = PS_ALIVE<br><br>cool.<br>thanks<br><br>a2k </i>
actually, i had them originally embedded in my classes, but got really frustrating to type player.playerstate = player.alive<br><br>i''d rather have player.playerstate = alive<br><br>but, the caps idea is good, especially since it''s fairly standard<br>so, i''m gonna use<br><br>player.PlayerState = PS_ALIVE<br><br>cool.<br>thanks<br><br>a2k </i>
------------------General Equation, this is Private Function reporting for duty, sir!a2k
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement