C++ programming in MS Visual Studio



C++ Programming in MS Visual 2003

1/27/2004 12:25 PM

Terminology:

Click: click the left mouse button once

Double click: quickly click the left mouse button twice

Right click: place mouse pointer over object and click the right mouse button once

Project: Visual Studio container for your C++ program and related files. When you click the “New Project” button Visual Studio creates a folder with the name you have given to the project. This folder will also contain files with the following extensions used by Visual Studio:

• .sln The solution file (see below)

• .vcproj A file containing information about this project

• .ncb A database used by C++

• .cpp The C++ main program file which you must create

• Any .h and additional .cpp files used by the main program

Solution: The top-level Visual Studio container which holds one or more projects

Item: A formal element of a project. Your C++ main program is an item. That is why it is created using the “Add New Item” button. Items must always be added to a project. Important: additional header files (.h) and C++ files (.cpp) usually are NOT items. They are created and opened using the “Open File” button (has folder on it). They are stored along with the ourUtils files in the project folder.

Debug Folder: When you click on the “Build” button to compile and link a program, Visual Studio will create a Debug folder which is placed in the active project folder. The Debug folder contains files with the following names or extensions:

• .obj The object file created by the compiler

• .exe This is the executable machine language version of your program which is loaded and run when you click the “Start” button.

• BuildLog.htm A web file containing the history of compile and linking operations for this project. You can view it with your web browser.

• .ilk A database file used by the linker

• .pdb Database files used by the debugger

• .idb A file used by the compiler when it rebuilds

Some of these files are very large. To release storage on your disk, it is advisable to delete the debug folder when you are completely finished with a program.

If the Start Page appears, select the following settings:

• Profile: Visual C++ developer

• At Startup: Show empty environment

Click the cross in the upper right corner to cancel the start page.

Click the cross to close all other unnecessary windows

If the Build buttons are not on the screen:

• Click “View” on the top command bar

• Click “Toolbars”, click on “Build”

• Drag the toolbar and dock it below the blue start arrow (middle top of screen below the white Debug window)

To create a new project:

1. Setup empty project folder (this also opens a solution containing the project)

• Click the “New Project” button (upper left)

• Click the folder for Visual C++ projects

• Click the icon for Win32 Console Project

• Enter the name of the folder for the project

• Browse to the directory where it will be stored and click OK

In the Win32 Application Wizard

• Click “Application Settings”

• Click the box for empty project

• Click the “Finish” button

(You should see a dark empty screen)

2. Create an empty C++ file

• Click the “Add New Item” button (upper left next to “New Project”)

• Click on the icon for C++ File (.cpp)

• Enter program name (for example, Jenny-2G)

• Click the “Open” button

(You should have an empty white screen)

3. Copy skeleton main program into empty C++ file

• Click “Open File” button (has folder on it)

• Click “Up One Level” button

• Double click on main.cpp

• Highlight the code, right click, and click “Copy” to copy to the Windows clipboard

• Click “File”, “Close” (on the top command bar) to close main.cpp

• On the empty white C++ screen right click and click “Paste”

(You should now have a skeleton C++ main program on screen)

4. Copy the ourUtils.h and ourUtils.cpp files to the project folder

• Click “Open File” button (has folder on it)

• If you are currently in the project folder, click the “Up One Level” button. Otherwise browse to the directory containing the ourUtils files.

• Highlight both ourUtils files (with the mouse pointer to the right of the first file, drag it down and then to the left to highlight both files)

• Right click and click “Copy” to copy both files to the Windows clipboard

• Double click on the project folder to open it. Otherwise browse until you are in the project folder.

• Right click on the white part of the screen and click “Paste”

(the two file names should appear in the directory of your project folder)

To run a C++ program:

• Click the “Build Selection” button (below the blue start arrow). This compiles and links the program. If not successful, edit the program to fix errors. Repeat this process until successful.

• Click the blue “Start” button (to the left of the white Debug window)

(Your output window with black background should appear)

To modify a previous project:

• Close any open solution: click “File”, click “Close Solution”

• Open the previous solution: Click “File”, “Open Solution”, and select the solution file (you should have a dark blank screen)

• Open your C++ program: Click “Open File” button (has folder on it)

• Browse to the project folder, double click on it to open

• Highlight the .cpp file, click the “Open” button

(You should see the C++ program on a white background)

Done with current project, want to start new project:

• Close current solution: Click “File”, “Close Solution”

• Follow procedure for creating a new project

Please report any discrepancies and any suggestions for improving this guide.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download