The difference was mentioned in the C ++ Programming Practice tutorial of Huazhong University of Science and Technology:
According to the idea of object-oriented, a program is also an object. Therefore, a program has its own life and death.
After compiling a program, C ++ executes the program as follows: (1) execute the start function.
Program initialization mainly refers to global variable initialization. (2) call the main function. (3) Execution
The receiving function is used to analyze the global variables (objects. So the following program will output,
Although the main function is empty:
# Include <stdio. h>
Int x = printf ("abcdef ");
Void main (){}
Now, let's talk aboutAbortIt is different from exit and return. Return, destructor
Main or local variables in the function. Pay special attention to local objects.
Memory leakage. Exit returns a local variable that does not parse the main or function, but executes the receiving function,
Therefore, global variables (objects) can be analyzed ).AbortDoes not parse the local variables in the main or function, or
The receiving function is executed, so global and local objects are not destructed.
Therefore, using return can avoid Memory leakage. It is used in C ++.AbortAnd exit are not good.
Habits.
Score.