title: How to change the variables of super class from subclass in C++?
body: <p>I am new to OOPs, so I was trying to create a program implementing inheritance.Here I am accepting the values for width and height in the derived class.Is there any way to reflect the same value in the super class ie Rectangle also.?ie if iam inputting 3 and 4 as breadth and height in Input() of RectangleArea then it should display the same value in Display() in Rectangle class.         </p>
  
  <pre><code>    #include &lt;iostream&gt;
  
      using namespace std;
  
      class Rectangle
      {
      public:
          int width;
          int height;
      public:
          void Display()
          {
              cout&lt;&lt;"Height"&lt;&lt;height&lt;&lt;",Width"&lt;&lt;width&lt;&lt;endl;
          }
      };
  
      class RectangleArea : public Rectangle
      {
      public:
          void Input()
          {
              cin&gt;&gt;width;
              cout&lt;&lt;" ";
              cin&gt;&gt;height;
          }
          void Display(int area)
          {
              cout&lt;&lt;"Area"&lt;&lt;area;
          }
      };
  
      int main()
      {
          Rectangle rect;
          RectangleArea rect1;
          rect1.Input();
          rect.Display();
          return 0;
      }
  </code></pre>