C + + Syntax

Source: Internet
Author: User

1, 16 mechanism and octal

A hexadecimal number corresponds to 4 bits, and the hexadecimal number starts with 0x. An octal corresponds to 3 bits, and the octal number begins with 0.

2. Original code and complement

The computer in memory is in the form of complement to store numeric value, positive complement is the original code itself, negative complement is its original code to take back plus 1, in addition, for the signed number, the highest bit 0 is positive, the highest bit 1 is negative.

3, bit arithmetic

Move left one bit, equal to the value of the original variable multiplied by 2, if the number of symbols left to move a symbol bit has changed to indicate that its value multiplied by 2 after overflow, is beyond the data type can be larger than the maximum value. Shift Right one represents divided by 2.

4. Initialization mode

int a=0 is generally used before; this type of initialization

There is also a more concise form of initialization:

int a (0);//use parentheses to initialize

5. Forced conversion

C-style cast, double a=2.9;

form one: int Xx=int (a);

Form two: int xx= (int) A;

C + + in the form of:

Type conversion operator < type descriptor > (expression)

int xx=static_cast<int> (a);

The type operation specifier can be:

Const_cast,dynamic_cast,reinterpret_cast,static_cast

6. C Style String

C + + Syntax

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.