How to share this data without global vars
<p>I'm trying to figure out the most logical, safe, efficient way to accomplish this, without using global variables.</p>

<p>Suppose I have a class:</p>

<pre><code>class SomeClass{
 public: someFunction(){...}
};
</code></pre>

<p>And another class instantiates <code>SomeClass</code> as a data member:</p>

<pre><code>class AnotherClass{
  SomeClass theTest;
  void anotherFunction(){...}
  int myDataInt;
 };
</code></pre>

<p>Now, I want the <code>someFunction</code> in <code>SomeClass</code> to be able to easily access the <code>myDataInt</code> in <code>AnotherClass</code>. One way would be to add an <code>int</code> parameter to <code>someFunction</code> that <code>AnotherClass</code> passes in. Perhaps that is the only decent way to do this. But I was hoping for a more "automatic" access between <code>someFunction</code> and <code>myDataInt</code>. Another option is to simply have <code>AnotherClass</code> set data in <code>SomeClass</code> that is equal to its own <code>myDataInt</code>. But then I have two classes storing the same data, which seems redundant. </p>

<p>Any other suggestions? Much appreciated.</p>
