コンパイラ エラー C2450
switch 式の求める数値の型 'type' が無効です
switch 式が無効な型に評価されます。 整数型、または整数型への明確な変換を伴うクラス型に評価される必要があります。 ユーザー定義型に評価される場合は、変換演算子を指定する必要があります。
次の例では C2450 が生成されます。
// C2450.cpp
class X {
public:
int i;
} x;
class Y {
public:
int i;
operator int() { return i; } // conversion operator
} y;
int main() {
int j = 1;
switch ( x ) { // C2450, x is not type int
// try the following line instead
// switch ( y ) {
default: ;
}
}