can anyone help me with this error message ?
The following code yields an error message:
Code:
// temp1.cpp
#include <iostream>
using std::cout;
void myM(char *);
int main()
{
myM("june");
return 0;
}
void myM(char *month)
{
switch(month)
{
case 'june':
cout << "\nJune";
}
}
after compilation i recieve an error message saying:
Quote:
error e2383 switch selection expression must be of integral type in function myM(char *)
can anyone tell me how to change the code so it doesnt yield an error message ?
Thanks !
Re: can anyone help me with this error message ?
it should work this way
Code:
#include <iostream>
enum month {
jan, feb, mar // ....
};
void myM(month m);
int main()
{
myM(jan);
return 0;
}
void myM(month m)
{
switch(m)
{
case jan:
std::cout << "\nJanuary";
}
}
K.