[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: C++

At 16:20 24/02/2003, you wrote:
Any ideas? I've tried passing a A* in the constructor for B, but the compiler doesn't
realize that A is a class when I try to compile, and complains about no type listed.

I seams to be a circular reference since A needs B and B needs A. This cannot be that
unusual, and has probably been solved before, I just don't know how.

Right now moy only though is to make parent a void* and the cast it to a A* in the
implementation of B. That removes all type checking though and I'd rather not abuse
void pointers like that.



It has been a while since i was at C++, but try the following:

Put both classes into the one h and cpp file, they are used together and should be together.

Then predefine the classes as the top of the header file:
class A;
class B;

Note you can only use the above for creating pointers to the predefined classes.


Damian Dowling IT Manager Pallas Foods Ltd

Phone: + 353 69 20200
Fax: + 353 69 20201
Email: damian-dowling pallasfoods com

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]