Compiler Error C2450 (Windows CE 5.0)
switch expression of type 'type' is illegal
The switch expression evaluates to an illegal type. It must evaluate to an integer type or a class type with unambiguous conversion to an integer type.
If it evaluates to a user-defined type, you must supply a conversion operator.
The following example shows how this error might occur.
class X
{
public:
int i;
} x;
class Y
{
public:
int i;
operator int() { return i; } // conversion operator
} y;
void main()
{
int j = 1;
switch ( x ) // error, x is not type int
{
default: ;
}
switch ( y ) // OK
{
default: ;
}
}
Send Feedback on this topic to the authors