Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!cs.utexas.edu!uunet!ncrlnk!ncratl!scotty!dspoon From: dspoon@scotty.Atlanta.NCR.COM (Dave Witherspoon) Newsgroups: comp.lang.c++ Subject: Re: A solution to the multiple inclusion problem Message-ID: <1035@scotty.Atlanta.NCR.COM> Date: 31 Oct 89 19:42:17 GMT References: <14240@well.UUCP} <1989Oct23.191634.6345@cs.rochester.edu> <3531@cadillac.CAD.MCC.COM> Distribution: comp Organization: NCR Corporation, E&M Atlanta Lines: 33 In article <3531@cadillac.CAD.MCC.COM}, vaughan@mcc.com (Paul Vaughan) writes: } } From: dspoon@ncratl2.Atlanta.NCR.COM (Dave Witherspoon) } } Say I have 2 classes, A and B. A contains a B*, and B contains an A*. } Thus, we have a circular dependency! One proposal (that I've tried): } } This may not solve your exact problem, but the way to do this is } simply } } [...solution omitted...] } } However, this does bring up a real issue. This sort of thing } works, but not when you try to define inline functions inside the .h } files. Putting inlines in .h files requires the inclusion of other .h } files, that would not otherwise be necessary. Since all base class } and component types must be defined before a class definition, a } single inline function can force a whole tree of .h files to be } included, (easily 10 more files) where they would not have been } necessary otherwise. I didn't go into all the other problems that happen when you don't get your dependent files included. A containing a B* made for an easy example, but (as you mention) additional problems show up when you need to invoke a B method (inline or not) from an A inline method. Also if A contained a B (not a B*), you're bit again. The Coggins approach I mentioned solve 3 problems: (1) many files open, (2) multiple opens of the same .h file, and (3) correct order of inclusion. -------------------------------David Witherspoon------------------------------- D.Witherspoon@Atlanta.NCR.COM | "Dolphins find humans amusing, but NCR Retail Systems Development/Atlanta| they don't want to talk to them." MY OPINIONS...ALL MINE!!! | - David Byrne