Do C++ enums Start at 0?

Per that standard [dcl.enum] The enumeration type declared with an enum-key of only enum is an unscoped enumeration, and its enumerators are unscoped enumerators. The enum-keys enum class and enum struct are semantically equivalent; an enumeration type declared with one of these is a scoped enumeration, and its enumerators are scoped enumerators. The optional identifier … Read more

How do you format the day of the month to say “11th”, “21st” or “23rd” (ordinal indicator)?

// https://github.com/google/guava import static com.google.common.base.Preconditions.*; String getDayOfMonthSuffix(final int n) { checkArgument(n >= 1 && n <= 31, “illegal day of month: ” + n); if (n >= 11 && n <= 13) { return “th”; } switch (n % 10) { case 1: return “st”; case 2: return “nd”; case 3: return “rd”; default: return … Read more