I'm having a small problem creating custom linked list. The List class contains an Iterator object and Iterator class contains List object. What do I declare first? It seems no matter what I am stuck...
Why don't you put Node and Iterator inside the List class since they belong to the list. Using them outside the list makes no sense. Of course the Iterator class must be public.
Line 23: There is no need to declare List as a friend of itself.
Line 36: Are you sure you want the list to be const here?
The way you handle this is to use a forward declaration to tell the compiler that class List exists. This lets you declare class Iterator. Once you have declared class Iterator, you can declare class list:
Those kind of errors occur a lot when programming with c++ and it is recommended detecting them as quick as possible in order to protect you code from errors that can harm you later. If it's getting too hard you there are programs that help detecting errors, such as checkmarx or others.
Good luck with it!
Ben.