title: how did the variables get memory without creating the object
body: <pre><code>#include&lt;iostream&gt;
  using namespace std;
  class A
  {
      private:
      int a,b;
  
      public:
      void setdata(int x,int y){
           a=x;b=y;
      }
  
      void show_data(){
           cout&lt;&lt;a&lt;&lt;b;
      }
  };
  
  class B: public A{
  };
  
  main(){
     B b1;
     b1.setdata(3,4);
     b1.show_data();
  }
  </code></pre>
  
  <p>How does <code>setdata</code> work even if we don't create an object of class <code>A</code> (how did the variables <code>a</code> and <code>b</code> get memory)? And how was it possible to access the private variables of <code>A</code> using an object <code>b1</code> of class <code>B</code>? I am surprised to see my program working properly.</p>