Using an object in unrelated class
<p>I have the following situation:</p>

<p>In project A, an object (say Obj1 of class A1) instantiates Obj2 of class A2.</p>

<p>Then, from Obj1, by many code paths, an object Obj3 (of class A3) can be instantiated.
The A3 class is in another project.</p>

<p>The stack trace from Obj1's main method to instantiating an object of class A3 is 20 calls deep, and there are at least 100 places in the code where the function that instantiates the A3 class is called.</p>

<p>Now I want to add a non-static method to class A2 (say test()), and be able to call Obj2.test() (not A2::test()) from all instances of class A3.</p>

<p>How could I go about this in the most reasonable way?</p>

<p>Edit:
some code:</p>

<pre><code> class A2
    {
      //...
      A2(string,string,...);
      double test();
    };

    A2::A2(string,string,...)
    {
      //...
    }

    double A2::test()
    {
      //return 4.2; //in reality it's more complicated
    }

    class A1{

    //...

      A2* Obj2;
    };

    A1::A1()
    {
      Obj2 = new A2(string,string,...);
    }

    A1:run()
    {
      //here there are many possible code paths (switches instantiating objects of other classes)
      //but all end up as: 
      A3* Obj3 = new A3();
      Obj3-&gt;test_wrapper();
    }

    class A3{
      //this is defined in another project, and I'd prefer that project doesn't reference A2 since A2  links against a couple of libraries...

      static double A3::test_wrapper();
    };

    static double A3::test_wrapper()
    {
      //if I had Obj2 here, I'd do:
      return Obj2.test();
      //but I don't... 
    }
</code></pre>
