THE STRUCTURE OF A C++ PROGRAM
Programs that will run as console applications under Visual C++ are programs that read data from the command line and output the results to the command line. To avoid having to dig into the complexities of creating and managing application windows before you have enough knowledge to understand how they work, all the examples that you’ll write to understand how the C++ language works will be console programs. This will enable you to focus entirely on C++ in the first instance; once you have mastered that, you’ll be ready to deal with creating and managing application windows. I’ll start by explaining how console programs are structured.
A program in C++ consists of one or more functions. In Chapter 1, you saw an example that was a Win32 console program consisting simply of the function main(), where main is the name of the function. Every C++ program contains the function main(), and all C++ programs of any size consist of several functions — the main() function where execution of the program starts, plus a number of other functions. A function is simply a self-contained block of code with a name that you invoke for execution by using the name of the function. As you saw in Chapter 1, a console program that is generated by the Application Wizard has a main function with the name _tmain. This is a programming construct to allow the name to be main or wmain, depending on whether or not the program is using Unicode characters. The names wmain and _tmain ...
Get Ivor Horton's Beginning Visual C++ 2012 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.