I have been trying to implement my own linked list class for didactic purposes.
I specified the \"List\" class as friend inside the Iterator declaration, but it doesn\'t
The problem is List has not been properly declared in Iterator.h. Instead, nest the Iterator class inside List (automagically making it a template), which you'll likely want to do anyway (to use List::Iterator instead of renaming it to ListIterator or IteratorForList, as you would to have more than one Iterator in a namespace).
template<class T>
struct List {
//...
struct Node {/*...*/};
struct Iterator {
// ...
private:
Iterator(Node*);
friend class List; // still required
};
//...
};
try adding a forward declaration
template <class T> class List;
at the start of Iterator.h
-- that might be what you need to allow the friend
declaration inside the Iterator
class to work.