From what I understand, you can cast an int to enum with a function-style cast or a C-style cast. However, the line using a function-style cast gives me the error "error C2228: left of '.c' must have class/struct/union" in Visual Studio. It works if I use a constant instead of i. Can someone explain to me why the function-style cast is giving me problems? Thanks.Code:#include <iostream> class Foo { public: enum Color { r, b, g }; Color c; Foo(Color cc) : c(cc) {} }; int main() { int i = 2; //Foo f(Foo::Color(i)); //function-style cast gives me an error //Foo f(Foo::Color(2)); //however this works Foo f((Foo::Color)i); //C-style cast works std::cout << f.c << '\n'; std::cin.get(); }