I have never been stuck on programming something before to the point I give
up... this is a first. I am programming what should be something very easy
in C++... using Templates. Here is the code, and the error I get:
--------------
namespace LIST {
template <typename T> struct Link;
template <typename T> class List;
template <typename T> class ListIterator;
// helper declarations
template<typename T> bool operator==(const List<T>::template ListIterator&,
const List<T>::template ListIterator&);
template<typename T> bool operator!=(const List<T>::template ListIterator&,
const List<T>::template ListIterator&);
template <typename T> class List {
public:
List();
virtual ~List();
private:
List(const List&);
List<T>& operator=(const List&);
public:
void insert(const T&);
class ListIterator {
friend bool operator== <> (const ListIterator&, const
ListIterator&);
public:
ListIterator(Link<T>* = 0);
ListIterator& operator++();
T& operator*(); // ListIterator i; *i cin >> *i;
const T& operator*() const;
private:
Link<T>* current_;
}; //ListIterator
ListIterator begin() const;
ListIterator end() const;
private: // List
Link<T>* head_;
};
}
---------------------------- Error
Script started on Mon Apr 11 22:34:01 2005
bash-2.05b$ make -f a6.make
g++ -Wall -pedantic -c main.cpp
In file included from main.cpp:1:
list.h:9: error: expected unqualified-id before '&' token
list.h:9: error: expected `,' or `...' before '&' token
list.h:9: error: ISO C++ forbids declaration of `parameter' with no type
list.h:9: error: `bool LIST::operator==(int)' must have an argument of class
or enumerated type
list.h:9: error: `bool LIST::operator==(int)' must take exactly two
arguments
list.h:10: error: expected unqualified-id before '&' token
list.h:10: error: expected `,' or `...' before '&' token
list.h:10: error: ISO C++ forbids declaration of `parameter' with no type
list.h:10: error: `bool LIST::operator!=(int)' must have an argument of
class or enumerated type
list.h:10: error: `bool LIST::operator!=(int)' must take exactly two
arguments
...........
-------------------------------------------------------------------------
Any ideas?
Thanks
Mat