The global main function
All C++ programs require a global function named main.
The main function is where execution of the program begins and ends.
The main function for our sample program is shown in Listing 2 with its body having been partially deleted for brevity. (I will discuss the body elements later.)
int main(){
//body code partially deleted
//for brevity
return 0;
}//end main
Listing 2
|
This is not the only syntax that can be used for the main function in C++. However, this is the only syntax that will be used in this course.