Question: In the UnsortedType list class, how can I make the items stored in the list generic (i.e. able to hold both strings and integers? //
In the UnsortedType list class, how can I make the items stored in the list generic (i.e. able to hold both strings and integers?
// IMPLEMENTATION FILE ( itemtype.cpp )
// Implementation depends on the data type of value.
#include itemtype.h
#include
RelationType ComparedTo( ItemType otherItem ) const
{
if ( value < otherItem.value )
return LESS;
else if ( value > otherItem.value )
return GREATER;
else return EQUAL;
}
void Print( ) const
{
using namespace std;
cout << value << endl;
}
void Initialize( int number )
{
value = number;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
