Message-ID: From: Robert Humphris To: "'djgpp AT delorie DOT com'" , "'darn AT xl DOT ca'" Subject: RE: compiling interdependent C++ classes Date: Wed, 4 Jun 1997 09:33:22 +0100 Encoding: 57 TEXT Precedence: bulk >---------- >From: Darren Grant[SMTP:darn AT xl DOT ca] >Sent: 02 June 1997 02:08 >To: djgpp AT delorie DOT com >Subject: compiling interdependent C++ classes > >Hello, > >I am having extreme difficulty compiling a collection of interdependent >C++ classes (using RHIDE). i.e. Given classes A and B, the situation is >like to A requiring B and vice versa. > >Each class has its own .cpp (class implementation only) and associated >header file (#include directives and class declaration only). While >BC++ has absolutely no problems with this arrangement, DJGPP returns all >sorts of errors consistent with the attempted use of undeclared classes. >(Not only that, but DJGPP isn't trapping circular #includes, which is >highly annoying!) > >Thanks. Can you not just declare the class prototypes in a headerfile: sharedHeader.h #ifndef _SHARED_HEADER_H_ #define _SHARED_HEADER_H_ class A; class B; class A { private: int a, b, c; B* ptrToBType; public: A(); ~A(); }; class B { private: int a, b, c; A *ptrToAType; public: B(); ~B(); }; #endif >