Class templates

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

class templates 0
class templates 4
Templates 2
Urgent help: print elements in queue 4
Classes,lists 4
Using a template getting LNK2019 error 0
How do I make this craftinfsystem Work 1
templates help 1

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,148
Latest member
ElizbethDa
Top