Very confused about including files

So I have a file, ParticleList.h, that is a class declaration for a linked list. A few other files declare and use this linked list in them. So I have #include "ParticleList.h" at the top of my main program. But if I don't have it in a function that the main program calls that also uses it, it says that ParticleList wasn't declared in that scope. But if I DO include it at the top of the called function, it whines about redeclaring ParticleList.

So what's the solution? Should I make it a .cpp instead and have it be explicitly called by my makefile?

Thanks!
You should post some example code to demonstrate the problem.
It also sounds like you forgot to add an include guard in the header file.
Alternatively, you could be redeclaring your class inside the header file, or you could be #including a header file where ParticleList is already defined.

-Albatross
Topic archived. No new replies allowed.