English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The return statement terminates the execution of the function and returns control to the calling function. It calls the constructor and the destructor. It is for " int main()
It returns an integer value.
The following is the syntax of the return statement.
return expression;
Here,
expression-The expression or any value to be returned.
The following is an example of the return statement.
#include<iostream> using namespace std; class Method { public: Method() { cout << "Constructor\n"; } ~Method() { cout << "Destructor"; } }; int main() { Method m; return(0); }
Output Result
Constructor Destructor
the functionexit()
It is used to immediately terminate the called function without executing further processing. Asexit()
The function is called, and the process is terminated. It only calls the constructor of the class. It is declared in the C language's "stdlib.h" header file. It does not return anything.
The following is the syntax exit()
void exit(int status_value);
Here,
status_value-the value returned to the parent process.
The following is an example ofexit()
.
#include<iostream> using namespace std; class Method { public: Method() { cout << "Constructor\n"; } ~Method() { cout << "Destructor"; } }; int main() { Method m; exit(0); }
Output Result
Constructor