Introduction to the data types of C + +

Source: Internet
Author: User

The C language contains 5 basic data types: Void, integer, float, double, and Char.

Type Describe
void Empty type
Int Integral type
Float Floating-point types
Double Double-precision floating-point type
Char Character type

C + + defines two additional basic data types: BOOL and wchar_t.

Type Describe
bool Boolean type with a value of true or False
wchar_t Wide character type

Type modifiers

Some basic data types can be modified by signed, unsigned, short, and long. When the type modifier is used alone, the default type is int. The following table is all the data types that can occur:

bool
Char
unsigned char
Signed Char
Int
unsigned int
Signed int
Short int
unsigned short int
Signed Short int
Long int
Signed Long int
unsigned long int
Float
Double
Long double
wchar_t

Type size and presentation range

The size of the base data type and the range of data that can be represented are related to the compiler and the hardware platform. The "Cfloat" (or "float.h") header file often defines the maximum and minimum values of the data that the base data type can represent. You can also use sizeof to get the size of the type (the number of bytes). However, many platforms use standard sizes for some data types, such as. int and float typically occupy 32 bits, char occupies 8 bits, and double usually occupies 64 bits. Bools are usually implemented in 8 bits.

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.