Template as a Class
Posted on 1998-10-04
Ok, I'm a student with an assign problem, but the book for the class does not explain how to use Templates and classes together. But a problem in the book has me writing a template class DataStore Here are the following member functions..........
Ok, teacher (very unhelpful lady), says program should be around 1 page.....pending whether you code it 3 files or 2.. either a main with header, or a main with header and it's own CPP file
Member functions are:
bool insert(const T& elt); // Insert elt into the private array dataElements having 5 elements of type T. The index of the next available location in dataElements is given by the data member "loc", which is also the number of data values in dataElements. Return false if there is no more room left in dataElements; otherwise, return true.
int find(const &T elt); // Search for element elt in dataElements and return its index if it is found and -1 if it is not in dataElements.
int numElts(); // Return the number of elements stored in dataElements.
T getData(int n); // Return the element at location "n" in dataElements. Generate an error message and exit if n < 0 or n >= loc
Please help if you can...... I am really stumped and in a bad position. At the least, can you direct me to a good tutorial site.... PLEASE HELP ASAP!!!!!!!
.....and the problem states: