Part of the problem here is that in List.cpp
you've included Node.h
twice.
- directly includes List.h which itself includes Node.h
- directly includes Node.h
I'm surprised that the compiler didn't warn you about this. It seems instead that it chose to redefine Node
hence you end up with two Node
values which aren't compatible. You need to add include guards to your header files to prevent double includes
List.h
#if !LIST_H
#define LIST_H
...
#endif
Node.h
#if !NODE_H
#define NODE_H
...
#endif
Also note that it's generally speaking considered bad practice to have using
statements in header files. Instead use namespace qualified names in headers and put the using
statements into the .cpp files.