Enumerations and functions naming problem

Dec 24, 2012 at 11:06pm
I have made 7 functions and wanted to use an enumeration in a switch.
The problem is that, i want the enumeration variables to be with the same name as the functions. Both are global, so how am I supposed to trick the computer and change the naming scheme? I used for example a start(); function and if i use enum{start} this won't work. If i use for example enum{start1} this works, but looks awful. Any help?
Dec 24, 2012 at 11:12pm
You can use a scoped enum. For example

enum class Functions { start, other_start, last_start };

EDIT: Or if your compiler does not support scoped enumerations you can place your enum in some namespace and use the nested name specifier everywhere in the code.
Last edited on Dec 24, 2012 at 11:27pm
Dec 24, 2012 at 11:41pm
ok I added an e_ to all of the enum variables. It worked fine
Is that the 'scoped' stuff?
Last edited on Dec 24, 2012 at 11:41pm
Dec 24, 2012 at 11:47pm
No it is not a scoped stuff. It is a name convention. I showed above how the scoped enumeration is defined.

Dec 25, 2012 at 11:51am
you mean to add it to the end?
for example start_e, end_e????
Dec 25, 2012 at 11:56am
I mean either to use a scoped enumeration or use an unscoped enumeration placed in some namespace.
Topic archived. No new replies allowed.