C + + Learning 1-bool data types

Source: Internet
Author: User

A Boolean type (BOOL) is a new basic data type added by C + +. The bool type is not defined in the standard C language, and if you need to use the bool type,
A programmer can customize a bool type by defining a macro definition statement as follows:

#define BOOL INT
#define FALSE 0
#define TRUE 1

That is, the int type is defined as bool, and the int type 0 and 12 values are defined as two values of type bool, true and false.

But in C + + it doesn't have to be so cumbersome, and C + + has a definition of bool type.

The bool type is one of the basic data structures of the C + + language, where the compiler gcc 4.8.1 and Visual C + + 2012 assign a 1-byte length to the BOOL type variable on the 80x86 processor.

The bool type takes a value range of only two values: True and False. When you do a logical operation, the default nonzero is ture.

Defining a BOOL type variable is also similar to the definition of other basic data type variables, as follows:


BOOL flag = TRUE;

C + + Learning 1-bool data types

Related Article

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.