I asked a couple of weeks back about problems with infinite loops in the compiler caused by 2 C++ classes having references to each other's header files and was pointed in the direction of using
//content of header here
This sure enough solved the infinite loop but Im getting errors from the compiler about classes being undefined which just doesnt make sense to me.
For example my program has 4 classes in total all of which are very simple but have references to each other.
The class diagram is here www2.simple.org/classes.pdf
The class Exchange compiles fine. The class's DDRoute, SnapshotCard and ServiceCode dont.
Taking DDRoute as an example, you'll see on the class diagram it has a pointer to Exchange and a pointer to SnapshotCard. SnapshotCard also has a pointer to DDRoute.
The header file for DDRoute is
using namespace std;
void setID(int pk);
void setCode(int c);
void setDestinationExchange(Exchange* e);
void setSnapshotCard(SnapshotCard* card);
When compiled GCC says:
andrew@p4-gw2k-black:~/Desktop/thg$ g++ ./DDRoute.cpp -c -I .
In file included from SnapshotCard.h:9,
ServiceCode.h:17: syntax error before `*'
ServiceCode.h:27: syntax error before `*'
ServiceCode.h:28: `SnapshotCard' was not declared in this scope
ServiceCode.h:28: `card' was not declared in this scope
ServiceCode.h:28: variable or field `setSnapshotCard' declared void
In file included from DDRoute.h:5,
SnapshotCard.h:24: `DDRoute' was not declared in this scope
SnapshotCard.h:24: parse error before `>'
SnapshotCard.h:41: parse error before `::'
SnapshotCard.h:45: `DDRoute' was not declared in this scope
SnapshotCard.h:45: parse error before `>'
SnapshotCard.h:46: `DDRoute' was not declared in this scope
SnapshotCard.h:46: `ddr' was not declared in this scope
SnapshotCard.h:46: variable or field `addDDRoute' declared void
I cannot see a reason for any of these errors. Its been given the headers for the other classes so why are they 'undefined' and also why is it moaning about methods that return void values.
The headers for the other 2 classes are at
I appreciate I've given you a lot of stuff here but if anyone can help me fathom this out (im sure its something basic ive done wrong) I'd be happy to compensate your time through PayPal.