Z
zfareed
if I have this template declaration:
________________________________________________________________________
template<class ItemType>
class SortedList
{
private:
int length;
ItemType values[MAX_ITEMS];
int currentPos;
public:
SortedList( ); // default constructor: lenght=0,
currentPos=-1
void MakeEmpty(); // let length=0
void InsertItem(ifstream inFile,ItemType x); // insert
x
into the list
void DeleteItem(ItemType x); // delete x from the list
bool IsFull( ); // test if the list is full
int LengthIs( ); // return length
void RetrieveItem(ItemType &x, bool &found); //
retrieve
x from the list, the
// boolean result is stored in found
void ResetList( ); // currentPos=-1
void GetNextItem(ItemType &x); // get the next element
from the list with
// respect to the currentPos
};
---------------------------------------------------------------------------------------------------------------------
The InsertITem function declared as follows:
template <class ItemType>
void SortedList<ItemType>::InsertItem(ifstream inFile,ItemType x)
{
........etc.
if i call this function from main, it gives an error that x is not
defined and if I include
ItemType x;
in main I get the error `ItemType' does not name a type .
I need to populate 2 lists inputted with data from two file. One
consists on integers and the other of floats. How do I do this using
the above class template?
________________________________________________________________________
template<class ItemType>
class SortedList
{
private:
int length;
ItemType values[MAX_ITEMS];
int currentPos;
public:
SortedList( ); // default constructor: lenght=0,
currentPos=-1
void MakeEmpty(); // let length=0
void InsertItem(ifstream inFile,ItemType x); // insert
x
into the list
void DeleteItem(ItemType x); // delete x from the list
bool IsFull( ); // test if the list is full
int LengthIs( ); // return length
void RetrieveItem(ItemType &x, bool &found); //
retrieve
x from the list, the
// boolean result is stored in found
void ResetList( ); // currentPos=-1
void GetNextItem(ItemType &x); // get the next element
from the list with
// respect to the currentPos
};
---------------------------------------------------------------------------------------------------------------------
The InsertITem function declared as follows:
template <class ItemType>
void SortedList<ItemType>::InsertItem(ifstream inFile,ItemType x)
{
........etc.
if i call this function from main, it gives an error that x is not
defined and if I include
ItemType x;
in main I get the error `ItemType' does not name a type .
I need to populate 2 lists inputted with data from two file. One
consists on integers and the other of floats. How do I do this using
the above class template?