CS 153 Data Structures I
Assignment #6
Due: 2/22/01
This assignment (#6) is designed to make sure that you UNDERSTAND everything
necessary for the next assignment (#7) which is a PROGRAM. The program
for assignment #7 will perform the same operations as Program #5 except
instead of manipulating ints it will be capable of manipulating
any data type using a generalized CBag class.This involves the following
topics/concepts:
-
Inheritence
-
Virtual constructors
-
Virtual destructors
-
Virtual member functions
-
Allowing a 'BaseClass' pointer to point to a 'DerivedClass' instance
-
Casting a 'BaseClass' pointer to a 'DerivedClass' type
-
Given:
-
BaseClass b, *pb;
-
DerivedClass d, *pd;
-
Something like the following will appear in your derived class
-
virtual bool operator==(const BaseClass & RHS)
-
{ if ( data == ((DerivedClass*)&RHS) -> data )
-
which goes along with something like:
-
virtual bool operator==( BaseClass &RHS ) = 0;
-
which would appear in class Node