C++: Can you return values of 0 or 1 as false and true in boolean functions? -
this question has answer here:
can c++ bool
functions return 0
false
, 1
true
so:
bool foo() { return 1; } bool foobar = foo();
?
yes, because 0
implicitly converted false
, 1
(or other nonzero value) implicitly converted true
.
not legal idea, however.
Comments
Post a Comment