title: Changing a Members variable value inside another classes function?
body: <p>I have been trying to make a texted based rpg game and have it so if you get a certain item it does certain things. Anyways what im trying to do is change a class variable from another classes function. how do I do this? I made up some sample code for you guys to look at exactly what im trying to do. There's no errors it just does not work. Thanks. </p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  
  // First class where we add values
  
  class B
  {
  public:
      void AddValueB(int VALUE);
      int GetValueB(void);
      B();
  
  
  private:
  int value;;
  
  };
  // constructor
  B::B(void)
  {
      value=100;
  }
  // where we add the passed in value to our main value variable. 
  void B::AddValueB(int VALUE)
  {
      value+=VALUE;
  
  }
  // returns the final value
  int B::GetValueB(void)
  {
      return value;
  
  }
  
  //**Second Class**
  
  class A
  {
  public:
      void SetValueA(int VALUE);
      int GetValueA(void);
      A();
  
  
  private:
      int value;;
  
  };
  // constructor
  A::A(void)
  {
  
  }
  // sets value
  void A::SetValueA(int VALUE)
  {
      B b;
      value=VALUE;
  // if value is one we pass 25 in B's AddValue() function which then should add 25 to the  value      variable. 
      if(value==1)
      {
          cout &lt;&lt; "Should Be 125?\n\n";
          b.AddValueB(25);
      }
  }
  // returns value 
  int A::GetValueA(void)
  {
      return value;
  
  }
  //main
  int main()
  {
      A a;
      B b;
      // set A's value to 1 to trigger the if statement in the function which should add 25 to B's   value variable. 
      a.SetValueA(1);
      //output the final value for B.....still 100...why?
      cout &lt;&lt; b.GetValueB();
  
      cin.get();
  
      return 0;
  
  
  }
  </code></pre>