Hi,
This is the first time using an iterator. I am trying to implement one for my linked list but I am stuck on the begin function. My compilation error is "'Iterator' does not name a type;" in List.cc (begin function). I know I am probably doing something very obiuosly wrong but have been stuck for 2 hours and don't know what to do. Plz halp.
begin() must be a member of the list class, not of the iterator class. The iterator has no way to find the list's head, all it has is a pointer to a node. Not to mention, it's a bit silly to construct an iterator to a random node just to get an iterator to the head.
As for why you're getting that particular error: to access non-static members of a class you need a pointer to the instance of the class that you're going to use. Without it, just the member of the class by itself is meaningless. How would the program know which instance you mean out of the possibly hundreds or thousands?