CSCI 230 Data Structures and Algorithms Fall 1998

Lab 1 (3-4 Sep)
SOLUTION

Solution files:
figure.cpp
figure.h
main.cpp
mainvect.cpp

  1. Pure Virtual After making Output_Info() pure virtual, main() can no longer contain a Figure variable.

  2. Cylinder Layout The Cylinder class should have two member variables, one of type float (height), one of type Circle (base). Cylinder should not store the radius, but should get that information from the Circle.

  3. Cylinder Constructor Note how the Cylinder constructor uses the radius to call the Circle constructor before the body of the function. This is necessary. The Circle contained in the Cylinder is going to be constructed, whether we want it to be or not, so we specifically tell it to use the radius we were given.

  4. Sort By Volume Just as we sorted by area by providing our own comparison function, we write a VolumeCompare function so we can sort by volume. Then we simply call the std::sort() function as we did before, with our new comparison function.


Last updated: 4 Sep 1998 by osmanb@rpi.edu