How to share parameters around a class - C++
<p>I have a class which I intend to use for performing calculations. I declare one static object of the class elsewhere which I use to obtain results. The class has one public function apart from the constructor.</p>

<pre><code>public:
    double getProbability(PlayerStats &amp;p1, PlayerStats &amp;p2, Score &amp;score);
</code></pre>

<p>As you can see, I have three objects as input parameters. My class then has two private functions which are called from <code>getProbability()</code>. One requires <code>p1</code> and <code>p2</code>, the other requires all three of the parameters</p>

<p>My question is this. Is it better to pass these objects as parameters to the function or is it better to create private member variables and use these.</p>

<p>So for example</p>

<pre><code>   double MyClass::getProbability(PlayerStats &amp;p1, PlayerStats &amp;p2, Score &amp;score){
            otherFunction(p1,p2);
            anotherFunction(p1,p2,score);
             ....
    }
</code></pre>

<p>or</p>

<pre><code>     double MyClass::getProbability(PlayerStats &amp;p1, PlayerStats &amp;p2, Score &amp;score){
            this-&gt;p1 = p1;
            this-&gt;p2 = p2;
            this-&gt;score = score;
            otherFunction();   //use member variables in these functions
            anotherFunction();
             ....
    }       
</code></pre>
