Reputation: 11
I am working on a traffic simulation program for school. My Simulation
class reads in a list of vehicles from an XML file, so I have included Vehicle.h
in my Simulation
class. I want my vehicle to be able to hold a pointer to the simulation object so that it can use the simulation's searchRoads
function. So I included Simulation.h
in my Vehicle
class.
When I did this, I got over 100 errors when I tried to compile. I'm pretty iffy on my C++ so if I committed some sort of cardinal sin, please let me know how to rectify this.
Upvotes: 0
Views: 5259
Reputation: 14471
Since operating systems have the ability to handle long file names I've started naming my include files so they reflect the code's position in the namespace:
namespace network {
class connection { bool send( char* stuff ); }
}
Would end up in the file "network.connection.h".
It helps keep things organized and reduces the chance of name collision of files.
Upvotes: 0
Reputation: 206616
Either, You are missing inclusion guards, leading to multiple inclusion of header files
Or
You are creating a Circular Dependency of your headers. You should be rather using Forward Declaration.
Post details of your code for more detailed answer.
Upvotes: 3
Reputation: 174
You learn something about include guards: http://en.wikipedia.org/wiki/Include_guard Hope this helps.
Upvotes: 0