title: C++ Pass an object into another object?
body: <p>I don't know if I've missed something, but I can't seem to figure out how to make this work, and couldn't find the answer online.</p>
  
  <p>Lets say I have a two classes, Class A, and Class B. (stored in separate files)</p>
  
  <p>Class A has a function <em>setName()</em> that sets a variable within a Class A object.</p>
  
  <p>Class B has a function <em>setOtherName()</em> that sets the value of a Class A object's name.</p>
  
  <p>So I set <em>setOtherName()</em> up like so:</p>
  
  <pre><code>void setOtherName(ClassA&amp; cla)
  {
  *cla.setName("foobar");
  }
  </code></pre>
  
  <p>then my main script looks like so:</p>
  
  <pre><code>Class A burger;
  Class B fries;
  fries.setOtherName(*burger);
  </code></pre>
  
  <p>this does not work in my orignal script, I get the following error:</p>
  
  <pre><code>error: no matching function for call to 'ClassB::setOtherName(ClassA*&amp;)
  </code></pre>
  
  <p>Any help is aprreciated! ( sorry for any confusion )</p>
  
  <p>Actual code:
      main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "quests.h"
  #include "player.h"
  #include &lt;string&gt;
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  int main()
  {
      quests GameQuests;
      player Player;
      GameQuests.quest1(Player);
      Player.main();
  
      return 0;
  }
  </code></pre>
  
  <p>quests.cpp:</p>
  
  <pre><code>#include "quests.h"
  #include "player.h"
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;cstdlib&gt;
  using namespace std;
  
  void quests::quest1(player&amp; charact){
      cout &lt;&lt; "By the way, what was your name?" &lt;&lt; endl;
      person1=4;
      system("pause");
      charact-&gt;setName();
  }
  </code></pre>