home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!wotan.compaq.com!twisto.eng.hou.compaq.com!gocart.eng.hou.compaq.com!giangd
- From: giangd@gocart.eng.hou.compaq.com (Giang Dao)
- Subject: class forward ref. in C++
- Message-ID: <1992Dec31.201340.13142@twisto.eng.hou.compaq.com>
- Sender: news@twisto.eng.hou.compaq.com (Netnews Account)
- Organization: Compaq Computer Corporation
- Date: Thu, 31 Dec 1992 20:13:40 GMT
- Lines: 30
-
- Dear C++ gurus,
- I have the following question :
-
- class A
- {
- ...
- B * bptr;
- ...
- }
-
- class B
- {
- ...
- A * aptr;
- ...
- }
-
- The C++ compiler doesnot allow this since B is not defined
- yet in class A definition and B can not be defined first
- since A is not defined yet. I can use void * instead and
- overcast the type but this is really inconvenient. Worse,
- I have members in A and B that have same names.
- This would result in no compilation errors if I typecast the
- wrong class. Any work-around without using void * and declare
- different member's names in A and B. I use the MS C++ compiler.
- Could some body try it on BC++ ?
- Theoretical this should be possible since aptr and bptr are
- just address holders and not depending on the structture of
- A or B.
- Thanks,
-