How to call overriden methods in all derived classes
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/5644338/how-to-force-child-same-virtual-function-call-its-parent-virtual-function-first">How to force child same virtual function call its parent virtual function first</a>  </p>
</blockquote>



<p>I have a class hierarchy where each derived class overrides a given virtual function and starts its implementation by calling the one in its parent class. The goal is to have each of the derived implementation to be executed, but I do not like the way I do it.</p>

<p>For example, I have this class:</p>

<pre><code>class base
{
public:
  void do_stuff() { do_something(); }
  virtual void do_something() { }
};
</code></pre>

<p>Then I derive this class on several levels:</p>

<pre><code>class derived_10:
  public derived_9 // which inherit from derived_8 and so on until derived_0
                   // which inherit from base
{
public:
  virtual void do_something()
  {
    // this will also call derived_8::do_something() and so on
    // until base::do_something()
    derived_9::do_something();

    // then, some stuff
  }
};
</code></pre>

<p>I'm looking for a solution that will make sure that all derived_x::do_something() will be called in sequence when base::do_stuff() is called, without having to expect the derived classes to do this themselves. Do you have an idea of the best way to get this behavior ?</p>
