Code:
#include <iostream.h>
const char* mmString(int mm)
{
static char mmList[12][20] = { "January ", "February ", "March ", "April ", "May ", "June ", "July ", "August ", "September ", "October ", "November ", "December " };
return(mmList[mm-1]);
}
int main()
{
int month;
for (month=1; month<13; month++)
{
cout << mmString(month) << endl;
}
return 0;
}
Making the array static would be the easiest way.
You cannot initialize class member this way. You would have to strcpy all values in the constructor.