title: concept of base, derive class and use them properly
body: <p><strong>you have to use the concept of base, derive class and use them properly. while doing it, I'm faced with some problems.
  Can you help me solve the issues ?</strong></p>
  
  <p>My Code : </p>
  
  <pre><code>#include &lt;iostream&gt;
  
  
  class Base {
      public:
      Base (int data) : _data(data){}
      virtual void printData(){
          std::cout &lt;&lt; "Base" &lt;&lt; _data &lt;&lt; std::endl;
      }
  
  private:
      int _data;
  };
  
  class Derived : public Base {
      public:
      Derived(derivdata) : Base(derivdata){}
      void printData(){
          cout &lt;&lt; "Derived " &lt;&lt; _data &lt;&lt; endl;
      }
  }
  
  
  int main(){
      Derived *var = new Derived(5);
      var-&gt; printData();
      Base* basevar = static_cast&lt;Base&gt;(*var);
      basevar-&gt; printData();
  }
  </code></pre>