So, I seem to expect this to be a simple answer, but I hack it a bit for a while and cannot solve this problem. Therefore, I have a specific Intersection class which, when included in any other header, gives me:
error C2061: syntax error : identifier 'Intersection'
This is my Intersection header:
#ifndef INTERSECTION_H #define INTERSECTION_H #include "Coord.h" #include "Road.h" #include "TrafficLight.h" class Intersection { private: int id; Coord * midPoint; Road * northRoad; Road * eastRoad; Road * westRoad; Road * southRoad; TrafficLight * trafficLight; public: Intersection(int, Coord *, Road *, Road *, Road *, Road *); ~Intersection(); void transitionTrafficLight(); int getId(); Road * getNorthRoad(); Road * getEastRoad(); Road * getWestRoad(); Road * getSouthRoad(); TrafficLight * getTrafficLight(); }; #endif
Now, if I try to use this class elsewhere, I get an error. For example:
#ifndef ROAD_H #define ROAD_H #include "Coord.h" #include "Intersection.h" #include <string> class Road { public: enum LaneCount { TWO_LANE = 2, FOUR_LANE = 4 }; Road(std::string, Coord *, Coord *, LaneCount, Intersection *, Intersection *, int); //shortened
In particular, in the Road constructor (and any other classes that reference Intersection ). I don't think this is a syntax issue, since Coord is a different class defined in the same way, and the compiler (VS 2008) does not complain about it. This is just Intersection in particular, which gives me this problem.: /
I put his homework - this is what he is for, although this is just a mistake that I can not get rid of, and not part of the problem.
Thoughts?