The default automatic conversion rule converts
char type to int type.
When operators are used for different data types, they are automatically upgraded to the higher ranked types.
The expression is automatically converted to the type of the final variable.
Type coercion: static_cast <DataTType> (Value)
DataType is the target data type to be converted, and Value is the variable or literal value to be converted.
C language style coercion conversion:
booksPerMonth = (double) books / months;
pre-standard C ++ form: (use less, just know)
booksPerMonth = double (books) / months; // put the data type before the operand, The parentheses are placed around the operand.
C ++ data type coercion
Guess you like
Origin blog.csdn.net/quietbxj/article/details/105506127
Recommended
Ranking