How to run one C++ program when multiple files are in one project:

How to Remove

When you want to compile one program but you have multiple .cpp files in the project, you need to exclude or remove the files you don't want in the project. For example, if you have hello.cpp and lab2.cpp in one project, and you want to compile hello.cpp, you need to remove lab2.cpp. If you value the old file, beware that you do not delete the file when you remove it.

To do this in Visual Studio, right click on lab2.cpp under the solution explorer, choose Exclude from Project. See the following image.

How to Add

When you want to add an existing C++ file to a Visual Studio project, here is what to do.