Make Object available to all methods c++
<p>Can anyone help me with this? basically I have a test class, wihtin this test class I have a number of methods which all use the same type of setup. Let me show you by example:</p>

<pre><code>class Test:public CxxTest::TestSuite
{
  public:

  void Test1(){/*...*/}
  void Test2(){/*...*/}
};
</code></pre>

<p>Each test method requires the same type of setup:</p>

<pre><code>Class c_objectName = AnotherClass::method("c_name","c_name","c_name");
class c_newObjectName = AnotherCLass::create(c_objectName);
</code></pre>

<p>I am currently setting this in every single method, because each of the above i started with "c_..." needs to be different.</p>

<p>I tried to make a "global method" that would take in a string to rename these each time, but then I cant seems to access them from the method calls. I tried the following:</p>

<pre><code>class Test:public CxxTest::TestSuite
{
  public:
  void method()
  {    Class c_objectName = AnotherClass::method("c_name","c_name","c_name");    &lt;--- cant access these 
       Class c_newObjectName = AnotherClass::create(c_objectName);
  }
  void Test1(){/*...*/}
  void Test2(){/*...*/}
};
</code></pre>

<p>Is there a way to put this in a "global method" of some sort so that I can access these from the methods?</p>

<p>Im really bad at explaining things so sorry and thanks in advance</p>
