Using Visual C++ 2005 ide



  1. Getting Started.

    The first time you solve a 122 programming exercise during week 1 of the term, you'll create a new Visual C++ Project. A Project is like a holder for the .cpp file you create to solve the exercise. (See pp. 17-23, ch. 1, for details.)

    For the programs we write in 122, a Visual C++ Project will contain a single .cpp file, the one containing function main.

  2. Two Containers: Solutions and Projects.

    Visual C++ provides two containers for managing projects: solutions and projects. The objects that these containers hold are called items.

    Solutions can contain one or more projects; projects can contain one or more files. (A solution file has the extension .sln)

    Visual C++ automatically generates a solution when you create a new project, so you never have to create a new one.

    In 122, your Visual C++ project will contain a single .cpp file and the automatically-generated solution will contain a single project.

  3. Creating a Project for the First Time.

    First create a folder named /122/vcpp-projects/. This is where you will save your Visual C++ project.

    As shown on p. 17-18 of Liang, use a Win32 Console Application template to quickly create an empty C++ project.


  4. Creating a new C++ Program for the Project.

    Now that you have a project, add a C++ program to it. The directions for creating a new program are given on p. 19-21 of Liang:

    Choose Project > Add New Item, then specify the file Type (C++), Name, and Location (choose an appropriate folder like /122/p2, or /122/p3, for example).

    You can then enter C++ code by hand, or copy-and-paste from a browser window, etc.

  5. Adding an Existing C++ Program to the Project.

    In addition to creating a new program, you can add an existing .cpp file to the project, save the .cpp file under a new name (if you want), and then edit the code to change the program.

    The .cpp file that you add to the project does not have to be in the folder containing the Visual C++ project. Our standard practice will be to store our .cpp files in, for example, /122/examples/, or /122/p1/, or /122/p2, etc.

  6. Finding the Executable Created by the Compiler.

    Visual C++ creates a folder named /122/vcpp-projects/122. When you compile a C++ program, the resulting executable will be named /122/vcpp-projects/122/debug/122.exe.

    If you double-click 122.exe, a console window will open automatically (the same as hitting the F5 key in Visual C++).