Home > Back-end >  C notes
C notes

Time:11-09

C + + notes (chapter 2)
10.2
The computer is the most basic function of data processing
2. C + + can deal with the basic data types have
A) integer type
B) real type
C) character type
D) Boolean type
3. C + + support the basic operation of arithmetic operations or logic operations
4. The emergence and development of the c + + :
Evolved from the C language development, was originally called "C with classes"
In 1983, officially named C + +
In November 1998 by the international organization for standardization (ISO) for approval as an international standard
On October 15, 2003 release version 2 C + + standard ISO/IEC 14882:2003
Released on August 12, 2011, the ISO version 3 C + + standard C + + 11, contains the core language of the new function, extend the C + + standard library
On August 18, 2014, announced the ISO c + + 14, its formal name:
"The International Standard ISO/IEC 14882:2014 (E) Programming Language c + +"
C + + 14 as a C + + 11 small extension, mainly provide bug fixes and small change

11.2.2
Namespaces can avoid naming conflicts


12.2.2
The character set of c + +
A) capitalization of letters: a to Z, a to Z
B) digital characters: 0 ~ 9
C) special characters:! # % ^ * _ +=- ~ & lt;>/\; ., '{} | ":? ()
2.



14.2.3
Constant
Directly in the source program data indicating its value cannot be changed during the whole program run, such data as constants,
Variable
In the process of running from the computer peripheral equipment (such as a keyboard, hard drive) is read, the value of the data in the process of the program is running allows the change, such data as variables,
From the keyboard input data
Iostream class object cin & gt;> Operation, can from the standard input device (usually a keyboard) read in data,
Data storage
For these data to store data, need to allocate memory space, the definition of a variable is in when allocating memory for naming a variable space,


15.2.4
Basic arithmetic operators
If + - */integer division, as a result, take more than integer %, operands precedence and associativity, first for the whole book, after add and subtract, at the same level from left to right + +, - (since, the decrement)


16.2.4
1. A comma operation and comma expression
The format
The expression 1 2

To solve the order and the results
First expression 1, again ask expression 2
The final result for the expression 2
Example:
A=3 * 5, a * 4 final results of 60

2. The relationship between operation and relational expression
Relationship between operations is one of the simple logic operations,
Priorities for: <=>=(high priority)
==!=(low priority)
Relational expression is one of the most simple logical expression
As a result of type bool value can only is true or false
Example: b, c=a + b, x + y==3
3.
Logic operation and logical expression
Logical operators. (a) & amp; & (with) lots (or)
Low priority: high
Logic operation result types: bool, values can only is true or false
Logical expression
For example: (a> b) & amp; & (x> y)



4. The conditional operator and conditional expression
General form
The expression 1? Expression 2:3 (expression) must be a bool type 1
Execution order
First expression 1
1 if the expression evaluates to true, to solve the expression, 2 is
Expressions for the final result 2
3. If the value of the expression 1 is false, is to solve the expression of 3,
Expressions for the final result 3



17.2.4
1. The sizeof operator
Grammatical forms: sizeof (type) or sizeof expression
The resulting value
"Type name" specified type, or the result of the "expression" type of bytes
Example: the sizeof (short)
Sizeof x
2. The arithmetic, bitwise and (& amp;)

(3) arithmetic, bitwise or

4. Bit operations - the bitwise xor
5. Bit operations - shift

6. An operation - take the


18.2.4

1. The data type conversion when mixed operation
Mixed operation when some binary data type conversion, implicit conversion operators (arithmetic operator, relational operators, logical operators, the operators and the assignment operator)

Requires two operands type in arithmetic operations and relations do not match the operand type if involved in operation, the build system automatically the data conversion (that is, the implicit conversion),
Type 2. The basic principle is to lower the high type data mixed operation data type conversion to a non arithmetic value of the Boolean type is assigned to the Boolean type,
Arithmetic value is 0 the result is false, otherwise the result is true to a Boolean value to a Boolean type, the Boolean value of false the result is 0, the Boolean value is true then the result is 1 to assign a floating-point number to an integer type, the result value will keep only integer part of the floating point number, fractional part will be lost,
3. To assign an integer value to a floating-point type, the decimal part down to zero, if the integer of space more than the capacity of the floating point types, there may be loss of accuracy when mixed operation data type conversion, the role of explicit type explicit type conversion is the result of the expression type is converted to a type specifier specified the types of grammatical form type specifier (expression) (type specifier) expression



19.2
1. The use of annotations
Method one: extended C method, the use of "/*" and "*/" quoted text
Method 2: the use of "lots", from "lots", know that it is in line with the tail, all characters are as the annotation processing,
Prev:C based
  • Related