![]() |
Visual Studio / Visual C++ FAQ |
Visual Studio questions |
|
| How do I build (compile and link) and execute a single-file program in Visual C++? Answer | |
| How do I build (compile and link) and execute a multi-file program in Visual C++? Answer | |
QUESTION: How do I build (compile and link) and execute a single-file program in Visual C++?
ANSWER: We will use the program basics.cpp (one of the stream I/O sample programs) as our example. Note that we are using Visual C++ version 6. However, the steps in Visual C++ version 5 are very similar.
You begin by opening the file basics.cpp.
![]() |
|
Once the file basics.cpp is open, you build an executable version of the program, as follows:
![]() |
|
Finally, you execute the program.
![]() |
|
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:
| Class | Header file | Implementation file | ||
| Calculator | calc.h | calc.cpp | ||
| Face | face.h | face.cpp | ||
| Interface | interf.h | interf.cpp | ||
| Main program | kidcalc.cpp |
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 6. However, the steps in Visual C++ version 5 are very similar.
![]() |
|
Then you specify the kind of Console Application.
![]() |
|
Once the project is created, you add files to the project, as follows:
![]() |
|
The resulting project is shown below in both Class View and File View.
![]() |
|
Once the files have been added to the project, you build (compile and link) and execute the resulting program as follows:
![]() |
|
Last updated: 7/99