beginner C++ question p62
in discussing enum's, the example for a bool enum is given
enum State : bool { On = true, Off};
I get this error when I include this line in my main() function:
Error 1 error C3168: 'bool' : illegal underlying type for enum c:\documents and settings\<user snipped>\my documents\visual studio 2005\projects\c++\ex2_01a\ex2_01a\ex2_01a.cpp 20
Here's my MFC Console .cpp file:
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
enum State : bool {On=true, Off} myState;
myState = On;
//I try the std::cout line below, but it's not in the book
//but my compile error is on the "enum State : bool" line
std::cout << "state = " << (int)myState << std::endl;
return 0;
}
Sincerely,
Brian
__________________
Sincerely,
Brian
|