I am trying to implement a simple list with iterator for practice, however I have encountered a compile error that I don't fully understand I had not been able to fix it. When I try to make pointer in my Iterator class to a Node I get compilation error as follows:
use of class template requires template argument list
Here is my headre file that produces the compile error:
#ifndef _MY_LIST_H
#define _MY_LIST_H
#include <memory>
template<class T>
class MyListItr;
template<typename T>
class MyList {
private:
int _size;
friend class MyListItr<T>;
public:
class Node {
private:
T value;
public:
std::unique_ptr<MyList::Node> next{ nullptr };
Node() = delete;
Node(T& value, MyList::Node* next) :value(value), next(next) {};
T getVal()const { return value; };
void setVal(T value) { this->value = value; };
~Node() {};
};
std::unique_ptr<MyList::Node> head;
MyList(const MyList<T>&) = delete;
MyList& operator=(const MyList<T>) = delete;
MyList() :_size(0), head(nullptr) {};
int size()const { return _size; };
void push_front(T);
T pop_front();
T front()const;
void remove(T);
MyListItr<T> begin() {return MyListItr(this->head); };
MyListItr<T> end();
typedef MyListItr<T> iterator;
typedef MyList<T>::Node value_type;
typedef MyList<T>::Node* pointer;
typedef MyList<T>::Node difference_type;
typedef MyList<T>::Node& reference;
};
template<typename T>
class MyListItr {
MyList::Node* data;
public:
MyListItr(MyList::Node*data) : data(data) {}
bool operator!=(MyListItr<T>const&) const;
MyListItr<T> operator++();
T operator*();
};
#endif
I would be gratefull for any help or direction as to where to look for any clues.