Difference between abort exit return

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.