Last active
February 12, 2016 17:01
-
-
Save kkabdol/5fce58a289d300e373a2 to your computer and use it in GitHub Desktop.
strongly typed enumerations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Animals { Bear, Cat, Chicken }; | |
//enum Birds { Eagle, Duck, Chicken }; // error! | |
enum class Fruits { Apple, Pear, Orange }; | |
enum class Colours { Blue, White, Orange }; // no problem! | |
Colours r = Colours::Orange; | |
// int n = r; // error ! | |
int n = static_cast<int>(r); // OK, n = 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment