title: can a class have virtual data members?
body: <pre><code>class Base{  
      public:  
          void counter();   
      ....   
  }
  
  class Dervied: public Base{  
      public:  
          ....  
  }
  
  void main()  
  {  
       Base *ptr=new Derived;  
       ptr-&gt;counter();  
  }
  </code></pre>
  
  <p>To identify that the base class pointer is pointing to derived class and using a derived member function, we make use of "virtual".</p>
  
  <p>Similarly, can we make derived data members "virtual"? (the data member is public)</p>