I am writing a iterator class which I am having no problem with yet my problem I am having now is I need to declare some methods as Iterator in my List class and I am getting errors from that.
template <class T>
class List
{
friend std::ostream& operator<< <>(std::ostream&, const List<T>&);
friend class Iterator;
private:
LNode<T>* head;
LNode<T>* tail;
public:
List();
~List();
List(const List<T>&);
List<T>& operator=(const List<T>&);
void clear();
int size() const;
bool empty() const;
const T& front() const;
T& front();
const T& back() const;
T& back();
void copyList(const List<T>&);
void push_front(const T&);
void push_back(const T&);
void pop_front();
void pop_back();
bool operator==(const List<T>&) const;
bool operator<(const List<T>&) const;
Iterator<T> begin() const;
Iterator<T> end() const;
Iterator<T> insert(Iterator<T>, const T&);
Iterator<T> erase(Iterator<T> pos);
void splice(Iterator<T>, List<T>&);
void remove(const T&);
};
The problem is with the declaration of these four methods.
Iterator<T> begin() const;
Iterator<T> end() const;
Iterator<T> insert(Iterator<T>, const T&);
Iterator<T> erase(Iterator<T> pos);
List.h:75: error: ISO C++ forbids declaration of âIteratorâ with no type
List.h:75: error: expected â;â before â<â token
List.h:76: error: ISO C++ forbids declaration of âIteratorâ with no type
List.h:76: error: expected â;â before â<â token
List.h:77: error: ISO C++ forbids declaration of âIteratorâ with no type
List.h:77: error: expected â;â before â<â token
List.h:78: error: ISO C++ forbids declaration of âIteratorâ with no type
List.h:78: error: expected â;â before â<â token
List.h:79: error: âIteratorâ has not been declared
List.h:79: error: expected â,â or â...â before â<â token
Those are the errors I am getting.