title: Passing member function data to another class c++
body: <p>was hoping I could get some help with this, I think I am just doing something stupid and the solution is obvious, but here we go. So I want to be able to pass data from class A's member function to class B to be used. I know inheritance can be used but it doesn't seem right as for my real case the two classes don't make sense to inherit.</p>
  <p>I have looked online and based most of the code shown below off of another post on here but am struggling to fully implement.</p>
  <p>Below is the code I have so far</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  
  class B
  {
  public:
      B();
      int memberFunctionOfB(const int &amp;temp);
  };
  
  
  // Later in class A's definition
  class A
  {
  public:
      A();
      int memberFunctionOfA()
      {
          int temp = 6;//results are stored in some temporary value, say temp
          B b;
          b.memberFunctionOfB(temp);
          return b.memberFunctionOfB(temp);
      }
  };
  
  
  int main(){
      B test1;
      cout &lt;&lt; test1.memberFunctionOfB() &lt;&lt; endl;
  }
  </code></pre>
  <p>What I thought would have happened here is that the value of temp is from class A is passed via reference. But I get this error:</p>
  <blockquote>
  <p>error: no matching function for call to B::memberFunctionOfB()</p>
  </blockquote>
  <p>Any help with this would be greatly appreciated,
  Thanks, Dean.</p>