title: c++ class-to-class data transfer
body: <p>I am working in c++, i want to input from text file then transfer to the variables in the class. I have 2 classes: <code>class A</code> and <code>class B</code> which are present by:</p>
  
  <pre><code>class A
  {
     public:
     double i;
     double r;
  
     double function(double s)
     {
        i = s*s+r;
        return i;
     };
  
  class B: public A 
  {
    public:
       A A;
       int c;
       double e;
       e = A.r;
       c = A.function(c);
       double h;
       h=e+c;
  };
  
  int main()
  {
     ifstream data;
  
     double f[3];
  
     data.open("A.txt", ios::in);
  
     for (int i = 0; i &lt;3; i++)
     {
       data&gt;&gt; f[i];
     }
     A A;
     A.r = f[0];
  };
  </code></pre>
  
  <p>the <code>r</code> that I input in <code>class A</code> didn't remain values when I use it in <code>class B</code>. I don't know how to deal with this problem. please help me!! thank you co much!!!</p>