title: Inheritance - Can't access base class data member in derived class
body: <p>One doubt in inheritance, I have two class named <strong>A</strong> and <strong>B</strong>.<br>
  <strong>A</strong> is <strong>Base Class</strong> and <strong>B</strong> is <strong>Derived Class</strong>.
  B Class inheriting two data members and two member functions of A Class.</p>
  
  <blockquote>
    <p>In derived class, accessing the <strong>static data member</strong> is Working but
    accessing the <strong>non static data member</strong> gives error. This same case is
    also for Member Functions. I can't access non static member function.</p>
  </blockquote>
  
  <p>If i access either static or non static <strong>variable | function</strong> inside any of derived class function it working fine.</p>
  
  <p>Why i can't access directly in a class. Why its not showing error when i access inside of any derived class function. Any one please clarify my doubts.</p>
  
  <p><a href="https://i.stack.imgur.com/tBEI5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tBEI5.png" alt="reference Image"></a></p>
  
  <pre><code> class A
  {
      protected string msg1;
      protected static string msg2;
  
      protected  string alert1() {
          return "Welcome";
      }
      protected static string alert2()
      {
          return "Welcome All";
      }
  }
  class B : A {
  
      string copyMsg1 = msg1;
      string copyMsg2 = msg2;
  
      string getMsg1 = alert1();
      string getMsg2 = alert2();
  
      void display() {
          msg1 = "";
          msg2 = "";
          alert2();           
      }
  }
  </code></pre>