Lab #6
Debug, Compile, and Run a C++ Program

What We're Gonna Do:

In this lab we'll get away from VisualWorks for a while and try playing with C++. Hopefully, after doing this lab you'll have a better feel for

The procedure is pretty simple. Save the buggy C++ source code that you find at this link as plain text. Call it campaign.cc just so that we can refer to it by that name throughout this document.

Then open up another window on your workstation and log into one of the acme machines. If you don't know all the details about this, ask your neighbors or the UA. The C++ compiler in the Rich cluster is broken, so we need to use the one on acme. It's suggested that you edit the file on your workstation, and just run the compiler on acme. That way you keep the load on acme lower and make editting your file faster.

Debugging the program

First thing you should do is read over the whole program. Figure out what it's trying to do. Look at the class declarations. Look at the class constructors and other methods. Look at the main() function. Spent enough time (about 5 to 15 minutes) just looking and building a picture of what the program does in your mind. It might be kind of familiar.

It will be helpful if now you grab a sheet of paperand draw the diagram describing the classes in this program. Look at this diagram and see if you can spot some of the things wrong with this source code.

After you have spent the time looking and drawing, dig into the code. Try compiling it (see below). If it doesn't work, fix what you think is wrong with it, and try again. Repeat. There are a number of debugging techniques that one can learn and derive along the way, but this isn't really the time or place to go into that.

This program has a number of syntactic errors. If you can fix it and make it compiled, it should work correctly, because there is no logic error in this lab. However, if you change the code too much, you may bring yourself some errors.

How to Compile and Run

To compile the program source code into something you can execute on the machine, you will use the a C++ compiler. It is generally called g++ and should be in your default path. It will generate an executable called a.out by default. To run it, simply type the name of the executable and hit return. To make the executable a bit easier to identify, you can pass an alternate name to the compiler. If you called the source code campaign.cc like we suggested, then the following will compile and execute the program:
       g++ -o campaign campaign.cc
       campaign

If you did that and had the compiler print a whole bunch of lines on your screen, then the program still has compile-time errors in it. Try to interpret the error messages, edit the source, and try again.

What you should turn in

You need to turn in your result as well as your fixed code. You can get a result file using this:
	campaign > result
Then, mail the result and source code to the TA with this command:
cat result compaign.cc | mail -s "lab6 - Section A/B/C Your Name" jy17@prism.gatech.edu
PLEASE: 1. Don't send those two files seperately; 2. Don't try to use MIME or other mail sender to attach your file; 3. Do send a mail with subject including "lab6", your section, and your name.