Is it bad to have functions return strings instead of ints? (C++) -


i'm still relatively new programming. i'm in process of working on game sdl , find myself wondering or not using bad habits.

for example, have function called titlescreen(), user decides mode of game enter.

i can either return value 0-3, process through if/else/else/else statement decide mode selected.

or

i can return string such "storymode", "freeplay", "tutorial", or "quit" , use decide mode.

i second mode because eliminates initital confusion on trying figure out mode selected, have feeling in of head there problem doing way.

in situation, best way return value?

in case should use enum listing states achieve readability without performance hit. example:

enum  mode {     storymode,     freeplay,     tutorial,     quit } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -