title: Is there a way to call an object's overridden base class methods?
body: <p>Given a pointer to a derived object, which has overridden some method <code>virtual void moo()</code>, is there a way to call the base's <code>moo()</code> method?</p>
  <p>One way is to create a sliced base class object from the derived object, but that would involve copying:</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  
  class A {
      public: virtual void moo() { std::cout &lt;&lt; &quot;moo from A\n&quot;; }
  };
  
  class B final : public A {
      public: void moo() override final { std::cout &lt;&lt; &quot;moo from B\n&quot;; };
  };
  
  int main() {
      A* a_ptr = new B; // could point to any A or A-derived object.
  
      A a(*a_ptr); // is there a way to get A::moo without doing this?
      a.moo(); // moo from A of course, but would be cooler without the copy above
  }
  </code></pre>
  <p>Why would I wanna do that you ask?</p>
  <p><em>So glad that you ask... not, because now I have to explain everything to you. Well A's <code>virtual void moo()</code> is actually more like <code>std::string serialize()</code>, which gives A's data members serialized into a <code>std::string</code>. Now when you have a big <code>std::vector&lt;A*&gt;</code> pointing to all sorts of derived objects and only the data from the base objects are needed (to be sent over network), it'd be nice to get only <code>A::moo</code>s, although those pointers in that vector point to all sorts of moos.</em></p>
  <p><em>(I'm aware of the possibility to 'simply' put a second <code>void moo2()</code> into A, that does not get overridden. But I'd also like to know if there's a third or fourth alternative.)</em></p>