home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!siena!mittle
- From: mittle@watson.ibm.com (Josh Mittleman)
- Subject: Re: classes referenced each in their declaration
- Sender: news@watson.ibm.com (NNTP News Poster)
- Message-ID: <1992Jul21.192039.5252@watson.ibm.com>
- Date: Tue, 21 Jul 1992 19:20:39 GMT
- Distribution: na
- Disclaimer: This posting represents the poster's views, not necessarily those of IBM
- References: <1992Jul21.174445.24733@menudo.uh.edu>
- Nntp-Posting-Host: siena.watson.ibm.com
- Organization: IBM T.J. Watson Research Center
- Lines: 26
-
- qincao@cs.uh.edu (Qin Cao) writes:
-
- > I need to declare several classes which are referenced each other in
- > their defination. If I used pointer, then it works fine, but I realy want
- > to use dot notation to refer the class member, instead of "->" notation
- > when using pointer. Unfortunately without using pointer, the C++ compiler
- > does not buy that, it gave a error message...
-
- Use references:
-
- class Y;
-
- class X {
- Y& b;
- };
-
- class Y {
- X& d;
- };
-
- You must initialize X::b in every constructor for X and Y::d in every
- constructor for Y, but otherwise everything should work just fine.
-
- ===========================================================================
- Josh Mittleman (mittle@watson.ibm.com)
- J2-C28 T.J. Watson Research Center, PO Box 704, Yorktown Heights, NY 10598
-