home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
- From: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Newsgroups: comp.lang.c++
- Subject: Re: Multiple Header Files Problem
- Date: 13 Nov 92 00:43:28
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 62
- Message-ID: <TMB.92Nov13004328@arolla.idiap.ch>
- References: <rmartin.721359424@thor> <1992Nov10.104447.12882@us-es.sel.de>
- <rmartin.721442494@thor> <1drjpsINN1jr@alnitak.usc.edu>
- <rmartin.721531576@thor>
- Reply-To: tmb@idiap.ch
- NNTP-Posting-Host: arolla.idiap.ch
- In-reply-to: rmartin@thor.Rational.COM's message of Thu, 12 Nov 1992 01:26:16 GMT
-
- In article <rmartin.721531576@thor> rmartin@thor.Rational.COM (Bob Martin) writes:
-
- [example with mutually recursive methods defined inside a class
- deleted]
-
- This is an excellent example of the dangers of inline functions. In
- this case, the reason that class a or b cannot be forward declared is
- because of the inline functions.
-
- Please don't start any false rumors: there is nothing "dangerous"
- about declaring a function inline (other than that it may be the wrong
- space/time tradeoff for your particular application).
-
- If the inlines are removed, then
- both classes could be forward delcared and the cycle could be broken.
-
- There are no "inlines" to be "removed". If you pull the method
- definitions out of the functions, you can still declare them "inline".
- Of course, you would have to change your include files around
- somewhat.
-
- What I don't understand about the example is why you would even put
- mutually dependent classes into separate include files. Some languages
- don't even let you define mutually recursive functions in separate
- compilation units, and I have not found that to be a problem.
-
- Thomas.
-
- PS: here is the example:
-
- coller@alnitak.usc.edu (Lee D. Coller) writes:
- >
- > Actually it doesn't entirely solve the circular dependency problem.
- > Consider two files, file a.h containing:
- >
- > #ifndef a_h
- > #define a_h
- >
- > #include "b.h"
- >
- > class a {
- > public:
- > b* _b;
- > void do_b_fnc() { _b->b_fnc(); }
- > void a_fnc();
- > };
- > #endif
- >
- > File b.h contains:
- >
- > #ifndef b_h
- > #define b_h
- >
- > #include "a.h"
- >
- > class b {
- > public:
- > a* _a;
- > void do_a_fnc() { _a->a_fnc(); }
- > void b_fnc();
- > };
- > #endif
-