Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actuallride

Posted 03 December 2012 - 06:45 PM

Some people prefer to place global enums inside a namespace instead:
[code=auto:0]
namespace Direction {
enum Type {
None,
Up,
Down
// ...
};
}


With C++11
you can just use
[source lang="cpp"]enum class Direction: unsigned char //You can even specify underlying data type{ None, Up, Down};[/source]

Note this doesn't allow implicit type conversion
[source lang="cpp"]int direction=Direction::None;//ErrorDirection direction=Direction::None//Ok[/source]

#1lride

Posted 03 December 2012 - 06:43 PM

Some people prefer to place global enums inside a namespace instead:
[code=auto:0]
namespace Direction {
enum Type {
None,
Up,
Down
// ...
};
}


With C++11
you can just use
[source lang="cpp"]enum class Direction: unsigned char //You can even specify underlying data type { DirectionNone, DirectionUp, DirectionDown};[/source]

PARTNERS