title: using derived class data members from base class method
body: <p>So i have been trying to use derived class data members from the base class and i am not able to figure out how to do that. I see a way to do this as just passing the member i need in parameter when i call the base class method but i was just thinking that there should be another way to do that. So i have replicated this as below.</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  class B;
  class A{
      public:
      display(){
          cout&lt;&lt;cord&lt;&lt;endl;
      }
      int cord = 25;
  };
  
  class B : public A{
      public:
      B(){
          A a;
          a.display();
      }
      int cord = 30;
  };
  
  class C : public A{
      public:
      C(){
          A a;
          a.display();
      }
      int cord = 35;
  };
  
  int main(){
      B b;
      C c;
      B.display();
  
  }
  </code></pre>
  
  <p>The above code as giving output as </p>
  
  <pre><code>25
  25
  25
  </code></pre>
  
  <p>What i want it to give out is </p>
  
  <pre><code>30
  35
  30
  </code></pre>
  
  <p>Every way to do this will be appreciated, whatever is better and if you want to me add something or anything ask in comments, i'll do right away.</p>