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: <1036@scotty.Atlanta.NCR.COM> Date: 31 Oct 89 19:47:41 GMT References: <14240@well.UUCP> <1989Oct23.191634.6345@cs.rochester.edu> <1144@odin.SGI.COM> Distribution: comp Organization: NCR Corporation, E&M Atlanta Lines: 25 In article <1144@odin.SGI.COM>, shap@delrey.sgi.com (Jonathan Shapiro) writes: > In article <1030@ncratl2.Atlanta.NCR.COM> dspoon@ncratl2.Atlanta.NCR.COM (Dave Witherspoon) writes: > > > >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): > > > > The following should do what you want. The trick is to recognize that > you don't really have a circular dependency at all: > > All C++ needs to know is that A/B are classes to construct a pointer > to them. It doesn't need to know what the contents are until you go > to use them. If instead my A class contains a B, then the compiler MUST know the full size of B. Or if my A class has an inline function that invokes some B method, then the compiler must see B's class declaration. I believe in either of these cases, then it is truly a circular dependency. In fact, we even have dependency "triplets". Other "wrapper" type methods I tried did not solve this problem. -------------------------------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