home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16181 < prev    next >
Encoding:
Internet Message Format  |  1992-11-12  |  2.2 KB

  1. Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
  2. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Multiple Header Files Problem
  5. Date: 13 Nov 92 00:43:28
  6. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  7.     Perceptive)
  8. Lines: 62
  9. Message-ID: <TMB.92Nov13004328@arolla.idiap.ch>
  10. References: <rmartin.721359424@thor> <1992Nov10.104447.12882@us-es.sel.de>
  11.     <rmartin.721442494@thor> <1drjpsINN1jr@alnitak.usc.edu>
  12.     <rmartin.721531576@thor>
  13. Reply-To: tmb@idiap.ch
  14. NNTP-Posting-Host: arolla.idiap.ch
  15. In-reply-to: rmartin@thor.Rational.COM's message of Thu, 12 Nov 1992 01:26:16 GMT
  16.  
  17. In article <rmartin.721531576@thor> rmartin@thor.Rational.COM (Bob Martin) writes:
  18.  
  19.    [example with mutually recursive methods defined inside a class
  20.    deleted]
  21.  
  22.    This is an excellent example of the dangers of inline functions.  In
  23.    this case, the reason that class a or b cannot be forward declared is
  24.    because of the inline functions.
  25.  
  26. Please don't start any false rumors: there is nothing "dangerous"
  27. about declaring a function inline (other than that it may be the wrong
  28. space/time tradeoff for your particular application).
  29.  
  30.    If the inlines are removed, then
  31.    both classes could be forward delcared and the cycle could be broken.
  32.  
  33. There are no "inlines" to be "removed". If you pull the method
  34. definitions out of the functions, you can still declare them "inline".
  35. Of course, you would have to change your include files around
  36. somewhat.
  37.  
  38. What I don't understand about the example is why you would even put
  39. mutually dependent classes into separate include files. Some languages
  40. don't even let you define mutually recursive functions in separate
  41. compilation units, and I have not found that to be a problem.
  42.  
  43.                     Thomas.
  44.  
  45. PS: here is the example:
  46.  
  47. coller@alnitak.usc.edu (Lee D. Coller) writes:
  48. >
  49. > Actually it doesn't entirely solve the circular dependency problem.
  50. > Consider two files, file a.h containing:
  51. > #ifndef a_h
  52. > #define a_h
  53. > #include "b.h"
  54. > class a {
  55. > public:
  56. >     b* _b;
  57. >     void do_b_fnc() { _b->b_fnc(); }
  58. >     void a_fnc();
  59. > };
  60. > #endif
  61. > File b.h contains:
  62. > #ifndef b_h
  63. > #define b_h
  64. > #include "a.h"
  65. > class b {
  66. > public:
  67. >     a* _a;
  68. >     void do_a_fnc() { _a->a_fnc(); }
  69. >     void b_fnc();
  70. > };
  71. > #endif
  72.