title: What is the benefit/use of dynamic_cast?
body: <pre><code>class Base 
  {
          public:
          virtual void print (){cout&lt;&lt;"Base"&lt;&lt;endl;}
  };
  
  class Derived :public Base
  {
          public:
          virtual void print (){cout&lt;&lt;"Derived"&lt;&lt;endl;}
  };
  
  int main(){
          Base *ptrb1=new Base();
          //it will print Base
          ptrb1-&gt;print();
  
          Base *ptrb2=new Derived();
          // it will print Derived
          ptrb2-&gt;print();
  
          Derived *ptrd=NULL;
          //what is the difference between 2ways?
          //what is the benefit of useing dynamic_cast?
          ptrd=dynamic_cast&lt;Derived*&gt;(ptrb2);
          ptrd-&gt;print();
  }
  </code></pre>
  
  <p>what is the benefit( or difference between) of dynamic_cast if we can make the base class see the members of derived class by adding virtual function and make the base Indicates to obj from derived class </p>