Learn C + + from C to C + + (bool type) with me

Source: Internet
Author: User
BOOL Type

C + + new type, representing logical true and false

1. The logical type is also called the Boolean type, its value is true (logical true) and False (logical false), the number of bytes stored in the different compilation system may differ, VC + + 1 bytes.

2. Declaration method: Boolresult;result=true;

3. Can be used as integers (true is generally 1,false to 0)

4. When converting other types of values to Boolean values, non-0 values are converted to true, and 0 values are converted to false

code example:

Main.cpp#include <iostream>using namespace std;//introduced namespace int main (void) {bool Result;result = true;cout<< Result<<endl;result = 100;cout<<result<<endl;return 0;}


The code above can be seen, even if the variable result is assigned a value of 100 but because it is a bool type, the output is also 1.


Learn C + + from C to C + + (bool type) with me

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.