void PrintNumberInBase(int number, BaseTypeT base) { }
using BaseTypeT = string; void PrintNumberInBase(int number, BaseTypeT base) { if (base == "ten") { cout << number; } else if (base == "trinary") { cout << IntToTrinary(number); } else if (base == "hex") { cout << IntToHex(number); } else if (base == "urnfield") { cout << IntToUrnfield(number); } ... } else { cout << "Unknown base " << base << endl; } }
using BaseTypeT = int; void PrintNumberInBase(int number, BaseTypeT base) { switch(base) { case 10: cout << number; break; case 3: cout << IntToTrinary(number); break; case 16: cout << IntToHex(number); break; case 222: cout << IntToUrnfield(number); break; ... default: cout << "Unknown base " << base << endl; } }
using BaseTypeT = int; const int BASE_10 = 1; const int BASE_3 = 2; const int BASE_16 = 3; const int BASE_URNFIELD = 4; void PrintNumberInBase(int number, BaseTypeT base) { switch(base) { case BASE_10: cout << number; break; case BASE_3: cout << IntToTrinary(number); break; case BASE_16: cout << IntToHex(number); break; case BASE_URNFIELD: cout << IntToUrnfield(number); break; ... default: cout << "Unknown base " << base << endl; } }
... const int BASE_URNFIELD = 4; const int BASE_MAYAN = 4;
enum class ClassTypeName { enumerator, enumerator, ... NONE}; enum class BaseT {TEN, THREE, SIXTEEN, MAYAN, URNFIELD, BINARY, NONE};
BaseT
enum class SuitT { HEART, SPADE, DIAMOND, CLUB, NONE};
const SuitT FIRST_SUIT = SuitT::HEART;
SuitT i; for(i = FIRST_SUIT; i != SuitT::NONE; i = NextSuit(i);
NextSuit()
SuitT::NONE
to an int, or in this case a size_t, will give us the number of valid suits.
const size_t SUIT_COUNT = static_cast(SuitT::NONE);