title: What is type erasure in C++?
body: <p>So I was reading <a href="https://davekilian.com/2014/10/24/cpp-type-erasure.html" rel="nofollow noreferrer">this article about type erasure</a>. But the code in that article seems partially incorrect, for example:</p>
  <p><a href="http://davekilian.com/cpp-type-erasure.html" rel="nofollow noreferrer">Repaired link</a></p>
  <pre><code>template &lt;typename T&gt;
  class AnimalWrapper : public MyAnimal
  {
      const T &amp;m_animal;
  
  public:
      AnimalWrapper(const T &amp;animal)
          : m_animal(animal)
      { }
  
      const char *see() const { return m_animal.see(); }
      const char *say() const { return m_animal.say(); }
  };
  </code></pre>
  <p>followed by</p>
  <pre><code>void pullTheString()
  {
      MyAnimal *animals[] = 
      {
          new AnimalWrapper(Cow()), /* oO , isn't template argument missing? */
          ....
      };
  }
  </code></pre>
  <p>These mistakes discouraged me from reading any further in the article.</p>
  <p>Anyways; can anyone please teach what type erasure in C++ means, with simple examples?</p>
  <p>I wanted to learn about it to understand how <code>std::function</code> works, but couldn't get my head around it.</p>