title: How to access a class member variable from a different class in c++
body: <p>I have the following 2 class header files (A.h and B.h), with a function inside each:</p>
  
  <p>class A
  {
  public:
  double f(double);
  };</p>
  
  <p>class B
  {
  public:
  double g(double);
  };</p>
  
  <p>Here are their corresponding cpp files:</p>
  
  <h1>include "A.h"</h1>
  
  <pre><code>double A::f(double variable1)
  {
  // do stuff on variable 1
  }
  </code></pre>
  
  <h1>include "B.h"</h1>
  
  <h1>include "A.h"</h1>
  
  <pre><code>double B::g(double variable2)
  {
  // do stuff on variable2 using f from A
  }
  </code></pre>
  
  <p>I would like to use function f (from A) inside function g (in B). How do I do this? </p>