Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Enum defined twice?

Author
Message
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 13th Apr 2009 07:26
When i run this, it says that enum eGameModes has been defined twice?
heres my code:

game_functions.cpp


game_functions.h:


main.cpp:
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 13th Apr 2009 08:20 Edited at: 13th Apr 2009 08:21
It doesn't appear to be defined twice, however your switch is incorrectly setup(unless you really intended it to be like that). C++ switches support 'fall though' so if I have, switch( 0 ){ case 0: cout << "test1"; case 1: cout << "test2"; }, both test1 and test2 will be outputted. This can be a very useful feature in many cases, however to have to not fall through simply add a break at the end of case. So: switch( 0 ){ case 0: cout << "test1"; break; case 1: cout << "test2"; }, though the last one doesn't need one as there are no other cases for it to fall into.

Another thing, enums are essentially more organized constants. As such, most people make all enum values upper-case like their defines(as you've done), it may make it easier to differentiate them if you make them upper case too.

Login to post a reply

Server time is: 2024-11-25 14:38:47
Your offset time is: 2024-11-25 14:38:47