title: Is there a way to get a derived class' type in a base class' function?
body: <p>I'm looking for a way to use the type of a derived class in a function in the base class, similar to templatized functions.</p>
  <pre><code>class Base
  {
      T foo() const
      {
          return T(*this);
      }
  }
  
  class Derived : public Base
  {
  }
  </code></pre>
  <p>This is similar to what I want to use this for, so that I don't have to override foo as a pure virtual function in every derived class. The goal is to find a way for T in foo to be the type of the derived class. For example, calling foo on an object of type Derived should call a version of foo that looks like
  this:</p>
  <pre><code>Derived foo() const
  {
      return Derived(*this);
  }
  </code></pre>
  <p>I know this probably isn't something you can do, but can anyone confirm?</p>