Visual C++: Adding a New Source (.cpp) File to a Project

Adding a New Source (.cpp) File to a Project

This video shows how to add a source (.cpp) file to an existing Visual C++ project. Assuming that you have a project open, you can follow these instructions:

  1. To begin, right-click the Source Files folder in the Solution Explorer pane on the left, mouse over Add in the submenu, and left-click New Item.
  2. This will open the Add New Item dialog. Left-click Visual C++ in the left pane under Installed Templates. The left-click C++ File (.cpp) in the middle pane.

  3. Below this, left-click the box next to Name: and type "CMyClass.cpp" for a class named CMyClass, and left-click the Add button to go on.
  4. The source file has now been added to the project and you should see it there. The file is actually located in the your project folder on your hard drive. If you open your project folder, you will see the new file there, as shown below.