1. The C language has a standard: the definition of a variable is generally written at the beginning of the function
2, the variable must be initialized, or the use of dirty data, for the following reasons:
If the variable is not initialized, it can be compiled successfully, but when executed, it is likely to error, we need to know how the operating system manages memory! Whenever an application is opened, the operating system allocates memory for it, memory addresses and memory units, and when the application initializes, it writes data to the memory unit, and when the operating system recycles, it does not empty the memory unit, so there is a lot of junk data. If the variable is not initialized, it will read the garbage data by default, some junk data will cause the program to crash, vc++2010 compiler can be aware that the variable is not initialized, debugging error, so the variable must be initialized before use!
3 . Two ways to define a constant pi:
1, #define Pai 3.14159
2, const float PAI 3.14159;
The first way: is to define PI as a symbol, at this time Pai is only 3.14159 alias, during compilation with 3.14159 to replace the value of pi, define equivalent to replace.
The second way: is to define PI as a variable, but tell the compiler its value is fixed, if in the program to try to modify its value, at compile time will error!
Basic knowledge of C + +