title: Accessing a base class member in derived class
body: <p>I have a simple class as below</p>
  <pre><code>class A {
  protected:
      int x;
  };
          
  class B : public A {
  public:
      int y;
  
      void sety(int d) {
          y = d;
      }
  
      int gety() {
          return y;
      }
  };
      
  int main() {
      B obj;
      obj.sety(10);
      cout &lt;&lt; obj.gety();
      getch();
  }
  </code></pre>
  <p>How can I set the value of the <code>protected</code> instance variable <code>A::x</code> from an instance of the derived <code>class B</code> without creating an instance of <code>class A</code>.</p>
  <p>EDIT: Can we access the value of <code>A::x</code> using the object of B? Like <code>obj.x</code>?</p>