cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Can type bool variables be assigned 0 in
Can type bool variables be assigned 0 in place of false and any integer in place of true?
Jul 8, 2011 at 10:31pm UTC
Anon1010
(20)
Can type bool variables be assigned 0 in place of false and any integer in place of true?
Sorry if this is a stupid question.
Jul 8, 2011 at 10:32pm UTC
Zhuge
(4664)
Yes. Integers are convertible to bool in the way you have described.
Jul 9, 2011 at 1:12am UTC
LB
(13399)
You will have to cast, however, and then when casting it will give you a performance warning because it converts to 0 or 1 rather than 0 or whatever value you want.
Topic archived. No new replies allowed.