#include <conio.h>
#include <iostream>
using namespace std;
enum MonthsOfTheYear
{
January,
February,
March,
April,
May,
June,
July,
August,
September,
October,
November,
December
};
const char* month_to_string(MonthsOfTheYear month)
{
static const char* month_names[12] = { "January", "February", "March", "April", "May", "June", "July",
quot;August", "September", "October", "November", "December" };
int index = (int)month;
return (index < 0 || index > 11) ? "Wrong month" : month_names[index];
}
& &
int main()
{
cout << month_to_string(March) << endl;
cout << month_to_string(November) << endl;
cout << month_to_string(July) << endl;
_getch();
return 0;
}
Comments
Leave a comment