1. Program execution begins in the main() function (or Winmain() if you're writing a windows program)
2. #include files are always optional, even in C++. The include files are lists of declarations for library functions. If you don't call the library functions, you don't need to declare them.
3. Execution of your program ends when your main() function returns.
Now, that said, there are exceptions. If you have a global object, that object's constructor gets called before main() so your first line of code might actually be there. But that's kind of a special case. Technically there are startup routines that initialize the C++ libraries and such, and they execute before your code. But for all intents and purposes your code starts at main().
If you have the following code snippet:
// declarations
int function1();
int function2();
int function3();
function1()
{
/* do stuff here */
return 0;
}
function2()
{
/* do stuff here */
return 0;
}
int main()
{
/*program execution starts here */
function3();
function2();
function1();
}
function3()
{
/* do stuff here */
return 0;
}
/* END FILE */
In this example, code starts at the main, then executes the function 3, function 2, and function 1, in reverse order. It doesn't make any difference here that function 3 is declared last in the file and function 1 is declared first. The execution starts at main() and calls them in the order you list there. When main is finished, the program ends. It doesn't continue on with function3, which happens to be after main in the code itself. If you don't call function3 from within your program it never gets executed at all.
Hope this helps.