If one of the operands in the modulo or remainder operation is negative, the result of these two operations depends on the machine.
If the result of the logical expression cannot be determined only by the value of the left operand, the value of the right operand-short circuit is obtained.
Relational operators are left-bound, such as if (I <j <k), which compares k with integer 1 or 0.
The right operand of the shift operation cannot be a negative number and must be a value Strictly less than the number of digits of the left operand.
Bitset usage:
Role: it is convenient to manage a series of bit spaces without programmers writing code themselves.
Initialization Method:
Bitset <N> varm (M)
Varm is the variable name.
N indicates the number of digits in the memory of this type, which is binary.
M indicates the initial value of the variable varm www.2cto.com
Instance:
# Include <iostream>
# Include <bitset>
Using namespace std;
Int main ()
{
Bitset <3> bs (7 );
Cout <"bs [0] is" <bs [0] <endl;
Cout <"bs [1] is" <bs [1] <endl;
Cout <"bs [2] is" <bs [2] <endl;
Return 0;
}
Description: declares a three-bit bitset variable. The initial value is 7, the binary code is 111, and the output value is 1 1.
Benefits: it is more direct and easier to read and write. It is more likely to be used correctly and suitable for low-level direct bit operations.
Conditional operators have a low priority. parentheses should be used.
After the pointer is deleted, the pointer is changed to a suspended pointer, which often leads to errors. The pointer should be set to 0, which clearly indicates that the pointer no longer points to any object.
One reason for Memory leakage: failed to delete the pointer pointing to the dynamically allocated memory because the block memory cannot be returned to the free storage zone.
You can also use delete to delete a const dynamic object.
Implicit type conversion (loss of precision may occur)
1) in a mixed expression, the operands are converted to the same type;
2) Expressions used as conditions are converted to the bool type;
3) If you use an expression to initialize a variable or assign a value to a variable, the expression is converted to the type of the variable.
Arithmetic conversion: before performing the arithmetic operation, convert the operator's operands to the same type and make the expressions of the same type.
It is strongly recommended that programmers avoid forced type conversion.
From left-brain design, right-brain Programming