title: pointer to abstract base class need some cast? C++
body: <p>I have 2 classes: </p>
  
  <pre><code>class MyAbstractClass
  {
  public:
   virtual const std::string&amp; getStr() const =0;
  }
  
  class MyRealClass : public MyAbstractClass
  {
  public: 
  virtual const std::string&amp; getStr() const { return m_str;};
  
  private:
  std::string m_str;
  }
  </code></pre>
  
  <p>I have in main:</p>
  
  <pre><code>MyAbstractClass* ptr = new(MyRealClass("some string"));
  </code></pre>
  
  <p>I want to get the string information stored in <code>MyRealClass</code> <strong>via a pointer to a base class</strong>. 
  Do I need to cast somehow <code>ptr</code> to <code>MyRealClass</code> to get info? or the run-time environment will be just smart enough to figure out that I am actually calling <code>getStr</code> from  <code>MyRealClass</code> ?</p>
  
  <p><code>ptr-&gt;getStr();</code> 
  or something else like <code>static_cast&lt;MyRealClass*&gt;(ptr)-&gt;getStr();</code> or even <code>dynamic_cast&lt;MyRealClass*&gt;(ptr)-&gt;getStr();</code> ? </p>
  
  <p><strong>In general, do we actually need to cast if we are using a pointer to a Abstract base class, not just to a simple (real) base class ?</strong></p>