Map
) from the existing class
Set
. We will demonstrate dynamic binding (polymorphism) by
including virtual functions and by processing an array of base class
pointers.
Set.H
and Set.C
from Project 3.
In Set.H
:
Display()
function so
that it takes an argument of type ostream&
with
default value of cout
:
void Display (ostream& os = cout) const;
Set.C
:
Display()
.
Display()
function:
ostream& operator << (ostream& os, const Set& s) { s.Display (os); return os; }
Map
. Begin with this
Map.H
. Add a header comment and a comment
for each member function. You may add additional data or function members
in the private section, but do not change the public section.
Implement the member functions in a file called Map.C
.
Test the new class. Here is a sample test
program and output.
Set.H
, revise the declarations for Display()
and the destructor so that these functions are virtual
.
Test these changes with a test program that creates and displays some sets
and maps, using an array of Set
pointers. You may want to
insert some temporary print statements into the destructors in
Set.C
and Map.C
to prove that they are getting
called. Here is a sample test
program and output.
Your makefile should be set up to make an executable named
Proj4
using source file Proj4.C
. Do not
submit your own Proj4.C
. Your project will be tested using
an undisclosed test program similar (but not identical) to the sample shown
in the previous step.
GetValue()
function in the Map
class. (15 points)