Setters/getters and hierarchical data structures
<p>I know it is considered a bad idea to have public fields in your class. But what's the best approach when your class includes numerous hierarchical data structures and fields? For example:</p>

<pre><code>class A {B d1; C d2; D d3;}
class B {E d4; F d5;}
class E {G d6; int d7;}
</code></pre>

<p>In C it is quite easy to access such a data structure, e.g. ptr_to_A->d1.d4.d7 and so on... But what's the approach when we use setters/getters?</p>

<p>When using setters and getters in C++, expressions like A.get_d1().get_d4().get_d7() don't seem convenient, and they force returning references. Since some structures are pretty big, returning by value seems a terrible idea.</p>

<p>Which approach or coding style do you use in these cases? Maybe getting rid of setters/getters and making these fields public?  </p>
