c++ - constructing enum with underlying "bool" type from a boolean? -
if define enum so:
enum foo : bool { left = false, right = true };
then try construct 1 boolean so:
int main (int ac, const char **av) { foo foo ( ac > 1 ); cout << boolalpha << bool(foo) << endl; return 0; }
it fails, works constructor so:
foo foo ( foo( ac > 1 ) );
why this? thought foo foo (...)
was explicit constructor call?
i don't think can this:
foo foo ( ac > 1 );
suppose define foo enum as:
enum foo : bool { left = false };
what happen if called:
foo foo(true);
you don't have appropriate enum value want initialize with.
Comments
Post a Comment