title: Why doesn't C++ have virtual variables?
body: <p>This might have been asked a million times before or might be incredibly stupid but why is it not implemented?</p>
  
  <pre><code>class A
  {
        public:
               A(){ a = 5;}
               int a;
  };
  
  class B:public A
  {
        public:
               B(){ a = 0.5;}
                float a;
  };
  
  int main()
  {
      A * a = new B();
  
      cout&lt;&lt;a-&gt;a;
      getch();
      return 0;
  }
  </code></pre>
  
  <p>This code will access A::a. How do I access B::a? </p>