1: But I'm having a hell of a time properly declaring, an iterator of forward_list, to the extent that I'm not sure if that is what I should be doing.
2: Should I be doing that?
3: Could I just use a pointer instead? If so, how do I properly declare it?
iterator is a nested class in whatever container class you're using. So simply declaring an iterator won't work... because it could be a vector<int> iterator, or a list<double> iterator... or whatever.
The full qualified name would be:
BUT... if you're using C++11 you don't even have to do that. You can just use auto (which is there for this very purpose):
auto myIt = myList.before_begin(); // <- auto automatically figures out which type you want
// based on the assignment.
Hah, thanks a ton. I just "figured it out" before I checked back here to get the thread deleted.
So, essentially, an iterator is just an overloaded pointer to a container's links?
If I pass the iterator by value is that essentially just passing another copy of the pointer? I'm pretty clear on how reference and value pointers work, due to experimenting, but not about iterators. They're confusing me right now.
If it helps to think of iterators as a pointer, that's a pretty safe way to look at them. They're basically pointers to a node in whatever container.
The key difference is that iterators are "smarter" in that incrementing them makes them look at the next node in the container... as opposed to pointers who simply look at the next area in memory when incremented.