On Tue, 30 Aug 2011 12:55:30 -0400, Timon Gehr <timon.g...@gmx.ch> wrote:

On 08/30/2011 06:23 PM, Steven Schveighoffer wrote:
On Tue, 30 Aug 2011 12:18:32 -0400, Timon Gehr <timon.g...@gmx.ch> wrote:

On 08/30/2011 06:00 PM, Steven Schveighoffer wrote:
On Tue, 30 Aug 2011 11:58:43 -0400, Timon Gehr <timon.g...@gmx.ch>
wrote:

On 08/30/2011 05:49 PM, Christophe wrote:
The fact that the code compile only if all interface methods are
implemented does not imply that the programmer knows which method he
implemented hooks and which does not.

interface I{
void method();
}

class C: I{
void method() {} // not a hook.
}

Why not? All a "hook" is is adding an entry into a base class' vtable.
This is no different, it's just the base "class" is an interface.

-Steve

As far as I can tell, a hook is overwriting an existing entry.

Nothing is "overwritten", what's written into the table is decided at
compile-time.

-Steve

It is conceptually "overwritten" at compile time: Copy vtable from parent and replace the overriden entries.

And that's no different from implementing an interface, or an abstract class that does not implement an interface completely -- copy the vtable and overwrite the entries.

And I am quite certain that what exactly is in the table is actually decided at link time.

The vtable's contents are known at compile time, however, they may not be resolved until link time. But they are not set to one method and then "overwritten" by another at link time, they are filled with symbols known at compile time, and then the symbols are resolved at link time.

-Steve

Reply via email to