The precedence table indicates that the assignment operator is a right-to-left combination
It's a good idea to define a const value to represent the number of elements in an array.
The same value of the same statement is incremented or decremented multiple times, and C + + does not define this behavior, which means that the statement produces different results on different systems.
The prefix operator is more efficient than the postfix operator
The prefix operator and the dereference operator have the same precedence, combining right-to-left;
The suffix operator takes precedence over the prefix operator and the reference operator, in a left-to-right manner.
When the C + + syntax allows only one expression, you can use the comma operator to combine several expressions into one, but you cannot group two declarations, and you can use a declaration statement expression to create and initialize two variables.
In all operators, the precedence of a comma expression is the lowest: it ensures that the first expression is evaluated first and then the second expression, whose value is the value of the last expression.
C + + provides 6 operators to compare numbers, or they can be used for characters, but not for C-style strings, but can be used with string class objects.
C-style strings are compared by applying the strcmp () function to return an assignment if the first string is less than the second, if it is greater than the return positive value, if the equality returns 0, that is, equal to false.
A C-style two string may be the same even if stored in a different length array, because the C-style string is defined by the trailing null character, not the length of the array in which it resides.
C + + typically uses a For loop for loop counting, and a while loop when it is not possible to know in advance how many times it will be executed.
The condition is considered true when the test condition is omitted in the For loop.
Write a delay loop:
The clock () function in the ANSI and C + + libraries Returns the system time that is used after the program starts executing.
The header file CTime provides a constant clocks_per_sec that is equal to the number of system units contained per second
Divide the system time by the constant to get the number of seconds, or multiply the number of seconds by that constant to get the time in system time
The clock_t type converts the resulting product result into a result appropriate to the current system
C++11 adds a range-based for loop:
Show only elements:
For (type: array) loop body
To modify an array element:
For (& type: array) loop body
Use CIN for Input:
Raw cin Input: Cin>>char
Ignore spaces and line breaks, tab characters
The input is buffered, and the input is sent to the program only after the user presses the ENTER key.
Use Cin.get (char) for input: Read spaces, line breaks, tab characters
properties |
cin.ge T (CH) |
ch=cin.get () |
the way to transfer the input characters |
assign parameter ch |
Assign the function return value to CH |
|
is Tream (True if bool conversion is performed) |
The return value of the function when it reaches EOF |
istream (false after bool conversion) |
eof |
After EOF is detected, CIN sets two bits (Eofbit and Failbit) to 1, which can be cin.eof () to see if Eofbit is set, and Cin.fail () can see if Eofbit or Failbit is set
The IStream class provides a function that converts a IStream object to a bool value, which is automatically called when Cin appears where the bool value is now required.
Because EOF is not a valid character encoding, it may not be compatible with char types. If you want to test EOF with Cin.get (), you must assign the return value to the int variable, which is cast to the char type when it is displayed.
The main purpose of get () is to convert Stdio.h's GetChar () and Putchar () functions to iostream cin.get () and Cout.put ()
C + + Primer Plus (v)--loops and relational expressions