Quote:
Originally Posted by Bench Code: #include <string>
enum { Continue, Won, Lost, Invalid };
int lookup( std::string str )
{
const int elems = 3;
std::string arr[elems] = { "Continue", "Won", "Lost" };
for( int i(0); i!=elems; ++i )
if( arr[i] == str )
return i;
return Invalid;
}
int main()
{
int i = lookup("Won");
switch( i )
{
case Continue:
//do something for Continue
break;
case Won:
//Do something for Won
break;
case Lost:
//Do something for Lost
break;
}
} |
You didn't name the enum, you passed an Int to that function, and returned a variable that doesn't exist. Did you mean to do that? I am missing anything?