Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think there are two issues at play here. One is that the code smells bad, as you say, and the second is that it doesn't compile on your system. Regarding the smell, yes, excessive use of the <code>friend</code> keyword often indicates bad OO design. It is generally better to give an object what it needs to do its job rather than pull something out of it, which is essentially what <code>friend</code> lets you do.</p> <p>Large numbers of inner classes, IMO, are not that bad, as they merely serve to keep classes within the scope of another. This helps keep the namespace less cluttered and allows you to use common names across different functional areas.</p> <p>Regarding the compilation issue, I tried to reproduce this on my system (Ubuntu 10.04, gcc 4.4.3, two years old at this point), and created this sample program:</p> <pre><code>class A { friend class B; int x; }; class B { class Inner { public: void foo(A&amp; a) { a.x++; } }; public: void bbb() { Inner i; A a; i.foo(a); } }; int main() { B b; b.bbb(); } </code></pre> <p>This compiled with no errors or warnings. I initially had nothing marked public, but I needed to add <code>bbb()</code> to create an instance of class <code>Inner</code>, and I had to add a public method of <code>Inner</code> so I could invoke it to do something with an <code>A</code>.</p> <p>The upshot is that I think your development system is out of date. The main developers clearly have no problem compiling their code, so the difference has to be with your system, or else they have configured their systems in a way that they are not telling you about. That being said, I think they could do more to make their code more portable and easier to build. In an open source project, that is to be expected if you want others to contribute.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload