Skip to content

Instantly share code, notes, and snippets.

@caloni
Created October 15, 2020 23:55
Show Gist options
  • Save caloni/32b138b0ff1cfc08face08d8d5fe1f9e to your computer and use it in GitHub Desktop.
Save caloni/32b138b0ff1cfc08face08d8d5fe1f9e to your computer and use it in GitHub Desktop.
#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