Debugging C++
The purpose of this exercise is to refresh your memory about C++
and debugging. Samuel Errorson is trying to implement a dynamic
linked list for his new Barnyard game: where he wants to keep track of
Animals that enter and exit the player's farm. To make sure his Linked
List code works correctly, Samuel wrote test code in TestList.cpp to
try out a couple List routines. Unfortunately Mr. Errorson can't seem
to get his test code working correctly, let alone compile.
There are 4 bugs nested in Samuel's code: identify each one, what
it's doing wrong, and fix it. By the end of the lab session, you
should have a working linked list implementation for Samuel's farm
animals, earning yourself a title on the credits screen of Samuel's
game.
Here are instructions to get yourself going:
- Import the project directory "A0/p1" into Eclipse, as
you did in the previous
exercise.
- Try building the project: making sure everything compiles. If
not, then you've found your first bug!
- Write down for each bug you find:
- The location of the bug.
- The incorrect behavior it's causing, and why.
- The fix you implemented.
- See the C++ tutorial
if you need to refresh your memory about C++. You may want to
focus in particular on the following sections:
- Basics
- Object Oriented
- Advanced
- Academic Conduct Guidelines
- Carefully read through the three pages that deal with plagiarism,
cheating, and academic misconduct:
You will need to confirm that you have read and understood these
guidelines. You should ask me right
away if you
have any questions, either by email or in person!
- Handin
- You will now practice handing in your project using the handin script.
- Make a new
directory called 314 in your home directory, and then
a subdirectory within that called p0. It's best to
have keep your working directories separate from your handin
directories, and just copy files over when you're ready to hand
things in.
- For this
assignment, you will only need to hand in a README file, not any
of your source code. This file
should be called README.txt and should be a plain ASCII
text file.
- The README.txt file for this assignment should include your
name, four-character account id, student number, a very brief
description of what changes you made to the P0 source, and a
brief writeup of the four P1 bugs as requested above (bug
locations, bug behavior, your fixes). It must also include the
statement "I have read and understood the cheating policies at
http://www.ugrad.cs.ubc.ca/~cs314/Vjan2013/cheat.html".
- Hand in this project with the command
handin cs314 p0
You do not need to be in any particular directory to run this
command; handin will automatically use the contents of
~/cs314/p0 no matter what directory you are in when you
run it.
- You can check what you have handed in at any time by simply
looking at the contents of the directory. You should also check
using handin -c to doublecheck that the handin was
successful.
CPSC 314 Jan 2013
Last modified: Sun Jan 6 22:07:30 PST 2013