In this lab we'll get away from Squeak 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. Save it onto your H: Drive, because we will be using that to do all our work.
Then open up another window on your workstation and log into one of the cc machines. This will be the system you use for reading mail from your cc account, which most likely is lennox or gaia. If you don't know all the details about this, ask your neighbors or the TA.
If you feel that you need extra help, here are a couple of links here that should be useful. The first one is a C++/SmallTalk comparison. The second one is an on-line C++ tutorial.
It will be helpful if now you grab a sheet of paper and 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.
You don't have to read everything in the comparison file. Just glance over the important stuff, and if you know C++ already, you may not have to read it at all. It's more of a refresher.
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. Always try to fix the top error first, because it may also be causing errors underneath it. Lather, rinse, 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 compile, it should work correctly, because there is no logic error in this lab. However, if you change the code too much, you may enter in additional errors yourself that aren't there.
/usr/local/bin/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.