Created
October 15, 2020 23:55
-
-
Save caloni/32b138b0ff1cfc08face08d8d5fe1f9e to your computer and use it in GitHub Desktop.
This file contains 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
#include <string> | |
#include <iostream> | |
enum string_code | |
{ | |
sc_1, | |
sc_2, | |
sc_3, | |
sc_none | |
}; | |
string_code hashit(std::string const& inString) | |
{ | |
if (inString == "1") return sc_1; | |
if (inString == "2") return sc_2; | |
if (inString == "3") return sc_3; | |
return sc_none; | |
} | |
int main() | |
{ | |
switch (hashit("3")) | |
{ | |
case sc_1: | |
std::cout << "1\n"; | |
break; | |
case sc_2: | |
std::cout << "2\n"; | |
break; | |
case sc_3: | |
std::cout << "3\n"; | |
break; | |
default: | |
std::cout << "none\n"; | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment