enum ENU{YES=0,NO,DONTKNOW};
void func(ENU e)
{
int n;
cout<<"1+1=";
cin >> n;
if(n==2)
cout<<e.YES;
else
cout<<e.NO;
if(ischar(n))
cout<<e.DONTKNOW;
}
The error is always displayed. Because my program is too small and poor formed.
You probably want something like this:
There’s no point in your example in passing the parameter ENU to func().
Also, you must test for ischar() first, to avoid entering any of the two other tests if it’s not necessary.
Note that outputing your enum value with “cout<< YES;” for example, will not write “YES” to the console, but only its numeric value “0”.
And a version which demonstrate the use of enum a little better:
Remark: ischar() is probably not working as you would expect, as you’re not giving it a character code.