Ask a weak question
Static _ cast & lt& gt () is a type conversion, which is a statement under C++, meaning to explicitly tell the compiler to convert one type of data into another type, and this conversion is carried out under the supervision of the programmer, and the compiler will not issue compilation warnings again. If the conversion is unsuccessful, the compiler will throw an error message.

Back to this topic, if you don't convert, you divide two integers and the result is still an integer (the remainder is ignored), and then convert this integer into a floating-point number (that is, assign this integer to a floating-point type, which is implicit conversion). After adding this conversion, floating-point numbers are divided by integers, and the result is floating-point numbers.

In addition, the old-fashioned transformation may be written as follows: double aspect = (double) width/height; This conversion is still compatible in C++, but it does not check the data type, which may lead to information loss or unknown consequences, and the compiler will issue a compilation warning for this.