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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -