Cześć, mam takie pytanie: czy jest możliwe używanie obiektów własnej klasy przy operatorze case w instrukcji switch? Próbowałem zrobić konwersję typu int, ale nie pomogło ;-(
Chodzi mi o coś takiego:
class MojaKlasa
{
public:
operator int const()
{
return ID;
}
private:
int ID;
};
inline int fun(MojaKlasa m_check, MojaKlasa m1, MojaKlasa m2)
{
switch(m_check)
{
case m1:
return 1;
case m2:
return 2;
}
}
Wywala mi błąd: error C2051: case expression not constant
Z góry dzięki za pomoc.