home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!think.com!ames!agate!darkstar.UCSC.EDU!cats.ucsc.edu!flynn
- From: flynn@cats.ucsc.edu (Eric Alan Flynn)
- Newsgroups: comp.lang.c++
- Subject: Re: Multiple Header Files Problem
- Date: 11 Nov 1992 22:06:37 GMT
- Organization: University of California; Santa Cruz
- Lines: 33
- Distribution: world
- Message-ID: <1ds05dINN8em@darkstar.UCSC.EDU>
- References: <1992Nov3.113121.3388@ntuix.ntu.ac.sg>
- NNTP-Posting-Host: am.ucsc.edu
-
- (message paraphrased) why won't this work?
- add the following line
- class B;
- This creates a forward declaration of the class B.
-
- >class A
- >{
- >public
- > B* pB;
- > void foo();
- >};
- >void A::foo()
- >{
- > pB = new B(this);
- >}
- >class B
- >{
- >public
- > A* pParentA;
- > inline B(A* pA) {pParentA = pA};
- };
-
- Note that the only thing you can do is use B to create a B* pointer,
- so if you want to members of A to access _methods_ of B,
- you will have to declare those methods of A out of
- line, after the delcaration of the class B.
-
- Hope this helps,
-
- Eric
-
- >TH Koh
- >gthkoh@ntuix.ntu.ac.sg
-