Download a ZIP'ed copy of the Lab 11 project and store it in the C:\FILES directory.
Go into the MS-DOS prompt and execute the following commands:
SwapEmare not reference variables.
Rather than running the program, step through it with the
debugger. Press F10 to move one statement
at a time through the
main routine. When the
yellow arrow reaches the call to
F11 to move into the
Then contine to press F10 to move through
the statements of
As you step through the program, pay attention to the
variables window at the bottom off your
Visual C++ window.
At first, it will display variables of
but, as your move into
SwapEm, it displays
The information displayed in a variables window is the contents of C++ function activation records.
Step to the statement
FormArg2 = Temp
Now move your mouse into the variables and move between the activation records of
SwapEm. You do this selecting from
a pull-down menu that is displayed when you click
on the down arrow
at the right end of the textbox labeled
SwapEmhas reference parameters. Again step through to the statement
FormArg2 = Temp. Show your instructor the activiation records for
This time you'll see two windows. One window is our
stoplights from Lab 10.
The North-South light should be a solid green, while
the East-West light is a blinking red.
Right now the second window is nothing more
than a magenta background.
Now press within the magenta. A car should appear!
This car will remain until the East-West light
is green for at least fifty
The only files you'll change in this lab are
If you'll look very carefully, you'll notice a slight difference
Lab 10 stoplite.cpp
and this one.
The difference is in the
Tick routine which now takes
a single argument called
carPresent represents a
car "pad" on the East-West road. It is non-zero when a car is present,
and it is zero when no car is present.
StopLight class so that it will go through
a single cycle to allow East-West cars
to cross the intersection a brief period after they right the signal.
Remember that you must hold the green
light in the East-West direction for at least fifty
to allow the East-West cars to pass.