home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!well!donovan
- From: donovan@well.sf.ca.us (Sean Donovan)
- Subject: Re: Multiple Header Files Problem
- Message-ID: <BxAA12.2Cz@well.sf.ca.us>
- Sender: news@well.sf.ca.us
- Organization: Whole Earth 'Lectronic Link
- References: <1992Nov3.113121.3388@ntuix.ntu.ac.sg>
- Date: Fri, 6 Nov 1992 07:27:01 GMT
- Lines: 33
-
- In article <1992Nov3.113121.3388@ntuix.ntu.ac.sg> gthkoh@ntuix.ntu.ac.sg (Koh Thong Hwee) writes:
-
- > [define class B which references class A which references class B]
-
- In C++ you can specify a forward reference to a class by just saying:
-
- class <class-name>;
-
- In that header module you can then declare a member variable to that class.
-
- Ex:
-
- class A;
-
- class B {
- private:
- class A *foo;
- };
-
- then go on to define your cyclic relation:
-
- class A {
- private:
- class B *bar;
- };
-
- This should solve your problem. You also want to be careful about using
- inline funcitons within your class definitions. If you reference a member
- function of class A when you define an inline function within class B you
- will run into trouble because class A has not been defined yet.
-
-
- Sean Donovan
-