C ++ Primer Plus Chapter III

3.1.1 variable name

C ++ naming rules

1. Use only alphabetic characters, numbers and underscores in the name (_)

2. The name of the first character can not be a number

3. distinguish between uppercase and lowercase characters

4. C ++ keywords can not be used as a noun

The live underscores two underscores names start with a capital letter and are reserved for implementation (compiler and used resources) used, a name beginning with underscore are reserved to achieve, as a global identifier

6.C ++ is no limit to the length of the name, the names of all the characters are significant, but some platforms have length restrictions

Usually more than one word name is the underscore to separate words, or write all of the other first small caps

3.1.3 integer short int long, and long long

Minimum length:

short at least 16

at least as long and short int

at least 32 bits long, and is at least as long int

long long as at least 64, and at least as long as the Long

3.1.4 unsigned type

Meaning that before the four kinds is an integer from negative to positive, and now this type is to increase the maximum value of an unsigned variable storage, and this value will not use unsigned types will be negative, so a bit positive integer meaning, declaration in front plus unsigned

E.g:

unsigned int rovert;

3.2 const qualifier

Begin statement in the program

const int Months = 12;

This allows the use Months in the program, and Months clear that what is indicated at 12, once initialized, the value is fixed, and the compiler will not modify the value of the constant, the usual rule is named after the first letter capitalized, of course, It is not absolute

3.3.1 Writing float

Index, d.dddE + n refers to the decimal point to the right by n bits, and d.dddE ~ n is a decimal point to the left by n bits

to sum up:

C ++ basic types divided into two groups, a set of values ​​is stored as an integer value by the composition, the other group is stored as a floating-point format from the composition, distinguished by the presence or absence and the amount of memory used for storing symbols integer value between , from the smallest to the largest integer time is: bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long and C ++ 11 new long long and unsigned long long, also One type wchar_t, its position in this sequence depends on the implementation, C ++. 11 and char32_t char16_t + type, their width and sufficient to store 16 32-bit character encoding, respectively, C ++ ensures char large enough to any member of the storage system the basic character set, and any member wchar_t can be extended character sets rainbow storage system, short of at least 16, and int is at least as long and short, long at least 32, and at least, and int the same length, the exact length depends on the implementation

Its value is represented by a character encoding, I / O system determines the character codes are to be construed as a digital or

Floating point type can represent a small number of values ​​and the maximum values ​​of the integer ratio can be represented by three kinds of floating-point types are float, double, long double, C ++ does not float to ensure long double, double than the length of long double, float generally 32-bit memory, double 64-bit, long double bit using 80-128

By providing a variety of different lengths, with a type of signed or unsigned, C ++ allows the programmer to select an appropriate data type in accordance with the specific requirements of

C ++ uses operator to provide arithmetic operations on digital type, addition, subtraction, multiplication, division and modulo, when two operators to use an operand operation, C ++ precedence and associativity rules may determine first performed which operating

Variable assignment, when used in different types of operation, using casts, C ++ will convert values ​​from one type to another type, many types of conversion are safe, i.e., may be changed without loss of data and under the conversion, for example, can be converted to int long, without any problem, for some other transformations, especially in floating-point type to an integer, you need to be more careful

Guess you like

Origin blog.csdn.net/u013693952/article/details/90726872