Virtual function calls
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Virtual function calls



This is a nit.

I don't think:

  The caller adjusts the 'this' argument to point to the class which
  last overrode the function being called. The result provides both the
  'this' argument and the vtable pointer for finding the function we
  want.

is very clear.  For example, consider:

  struct S1 { virtual void f(); };
  struct S2 : virtual public S1 { virtual void f(); };
  struct T : virtual public S1, virtual public S2 {};

This is legal C++, but is `S2' or `S1' the base which last overrode
`f'?  The answer is `S2', but we need to find a better way of
expressing this.

I think its easiest to use terms straight out of the standard:

  The caller adjusts the `this' argument to point to the class
  that contains the unique final overrider (as defined in
  [class.virtual]) for the function being called.  The result provides
  both the 'this' argument and the vtable pointer for finding the
  function we want.

--
Mark Mitchell                   mark@xxxxxxxxxxxxxxxx
CodeSourcery, LLC               http://www.codesourcery.com