Does it make any sense or not?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A boolean
trueis, well, a boolean value. Use it whenever you want to express that a certain binary condition is met.The integer literal
1is a number. Use it, whenever you are counting something.Don’t use integers for booleans and vice versa. They are different.
Consider a variable
int isEnabled. Of course, I can guess that0and1may be the only intended values for this variable. But language-wise, nothing keeps me from assigning4247891. Using a boolean, however, restricts the valid values totrueandfalse. This leaves no room for speculation.(C++ int’s and bools are somewhat convertible, but it’s generally frowned upon)