Will discuss running and compiling programs bit
8 | 1. |
|
---|
As you may have already figured out, you will be using a C++ source file from the available file types. There are two kinds of files you will be using during the course of the book—C++ source files and C++ header files. I will go over the differences between them later, for now let’s use a C++ source file and specify its name; as with projects, you will use a terminology throughout the whole book to maintain some consistency. Source files will be identified by the program number and by the objective of the file with the file extension .cpp so that Visual C++ identifies the file as a valid C++ source file. Name your file 01 Main.cpp, 01 from the program num-ber, and Main because this is the main, and in this case, the only part of your pro-gram. As you progress, you will separate the functionality of your program in different files; for example, a part of the program that manages the game sound
Figure 1.3
As you can see, you can also specify the location of the file like you could with the location of the project. For now, leave the default location chosen by Visual C++, which is usually the project directory.
Do you remember the talk about workspaces? Well, if you had various other pro-jects in your workspace you could select to which project you would add the new file, but since you only have one, leave it like that.
Make sure you have it all. First create a workspace for the projects, and then create a project for your program. After this is done, add a new source file to the project. Now you’re ready to type in the listing.
Type the following code into the file you created earlier and then press Ctrl+F5 to run it. I will discuss running and compiling programs in a bit, but for now just do it.
5:
6: /* Start */
11: }