![]() |
Visual C++ Build Tutorial |
QUESTION: How do I build (compile and link) and execute a single-file program in Visual C++ starting from an already existing C++ file (.cpp extension)? ANSWER: We will use the program ruleof72.cpp as our example. Note that we are using Visual C++ version 6. However, the steps in Visual C++ version 5 are very similar. Open Visual C++. 1. You begin by opening the file ruleof72.cpp as follows: 1a. Select File | Open.
1b. An "Open File" window should appear. Find the directory on your harddrive (usually C:) where your ruleof72.cpp file is stored.
1c. Select ruleof72.cpp and click on Open.
1d. Visual C++ will then display the file ruleof72.cpp in the code window.
2. The standard "windows style" text editing functions are available such as Copy, Cut and Paste.
3. Once the file ruleof72.cpp is open, you build an executable version of the program, as follows: 3a. Select Build | Build.
3b. Visual C++ will ask if you want to create a default project workspace. Select Yes.
4. Finally, you execute the program as follows: 4a. Select Build | Execute ruleof72.exe.
4b. Visual C++ will run the program as a separate application in its own (MS-DOS) application window. Note that the program ruleof72 is included on the task bar at the bottom of the screen.
4c. Type the appropriate input and press enter. The program output is written to the ruleof72 application window. As shown, press any key to end the run of the program and close the ruleof72 application window.
5. Now close the Project Workspace (and get ready for your next program) by selecting File | Close Workspace. Visual C++ will ask if you want to close all document windows. Select Yes.
QUESTION: How do I build (compile and link) and execute a single-file program in Visual C++ starting from an new, empty file? NOT YET AVAILABLE
QUESTION: How do I build (compile and link) and execute a multi-file program in Visual C++? ANSWER: We will use the children's calculator program as our example. This program consists of the following C++ classes and associated files:
Suppose that these files are in the directory c:\cs331\kidcalc. The following steps will create a new project. Note that we are using Visual C++ version 5. However, the steps in Visual C++ version 4 are very similar.
Once the project is created, you add files to the project, as follows:
The resulting project is shown below in both File View and Class View.
Once the files have been added to the project, you build (compile and link) and execute the resulting program as follows:
9/99 |