OK I been workin on this prog for the last 4 hours or so...I got it down to one last error...Its 5am and I cant find what the problem is, I am hoping a fresh set of eyes will see the error.
Code:
Line # Statement
------ ---------
0001 using namespace std;
0002 #include "List.h"
0003 #include <cassert>
0004 #include <iostream>
0005 template <class T> List<T>::List()
0006 {
0007 current_size = 0;
0008 }
0009
0010 //====================================================
0011 template <class T> List<T>::List(const List &l)
0012 {
0013 int i;
0014 for (i = 0; i < l.current_size; i++)
0015 data[i] = l.data[i];
0016 current_size = l.current_size;
0017 }
0018
0019 //====================================================
0020 template <class T> int List<T>::get_size() const
0021 {
0022 return current_size;
0023 }
0024
0025 //====================================================
0026 List &List::operator=(const List &l)
0027 {
0028 int i;
0029 for (i = 0; i < l.current_size; i++)
0030 data[i] = l.data[i];
0031 current_size = l.current_size;
0032 return *this;
0033 }
0034
0035 //====================================================
0036 template <class T> T &List<T>::operator[](int index)
0037 {
0038 assert(index >= 0 && index < current_size);
0039 return data[index];
0040 }
0041
0042 //====================================================
0043 template <class T> bool List<T>::append(const T &item)
0044 {
0045 if (current_size < CAPACITY)
0046 {
0047 data[current_size] = item;
0048 current_size++;
0049 return true;
0050 }
0051 else
0052 return false;
0053 }
0054
0055 //====================================================
0056 template <class T> void List<T>::traverse(void process(const T &item))
0057 {
0058 for (int i = 0; i < current_size; i++)
0059 process(data[i]);
0060 }
0061
0062 //====================================================
0063 template <class T> bool List<T>::insert(const T &item, int pos)
0064 {
0065 if(pos < 0 || pos > current_size || pos >= CAPACITY)
0066 return false;
0067 else
0068 {
0069 for(int i = current_size;i > pos ; i--)
0070 data[i] = data[i-1];
0071 data[pos] = item;
0072 current_size++;
0073 return true;
0074 }
0075 }
0076
0077 //====================================================
0078 template <class T> bool List<T>::erase(int pos)
0079 {
0080 if (pos < -0 || pos >= current_size)
0081 return false;
0082 else
0083 {
0084 for (int i = pos;i < current_size; i++)
0085 data[i] = data[i+1];
0086 current_size--;
0087 return true;
0088 }
0089 }
0090
0091 //====================================================
0092 template <class T> void List<T>::print()
0093 {
0094 for (int i=0; i<current_size; i++)
0095 cout << data[i] << endl;
0096 }
0097
0098 //=================== MAIN ===========================
0099 //====================================================
0100 int main(void)
0101 {
0102 int index;
0103
0104 List<int> intlist;
0105 intlist.insert (10,0);
0106 intlist.insert (20,0);
0107 intlist.insert (30,2);
0108 intlist.insert (40,1);
0109 intlist.erase (2);
0110 cout << "Integer List" << endl;
0111 intlist.print();
0112
0113 List<float> floatlist;
0114 floatlist.insert (1.5,0);
0115 floatlist.insert (2.3,0);
0116 floatlist.insert (1.5,0);
0117 floatlist.erase (2);
0118 floatlist.insert (6.5,0);
0119 floatlist.insert (7.2,4);
0120 floatlist.erase (0);
0121 cout << "Float LisT" << endl;
0122 floatlist.print();
0123
0124 return 0;
0125 }
--- Compiling List.cpp...
List.cpp:26: error: expected constructor, destructor, or type conversion before '&' token
List.cpp:26: error: expected `,' or `;' before '&' token
--- Compilation failed...
--- No execution.
There is the error at the bottom,I dont really understand what it is saying but I am expecting it to be something simple, If you can find the prob I would greatly appreciate it.
Thanx in Advance..