Page 1 of 1

Quick question about interfaces.

Posted: Mon Feb 02, 2004 6:26 pm
by GedB
Exactly what functionality does an Interface provide?

Is there any Com specific functionality. For example, is IUnknown implemented by the compiler?

Or is it just a C++ vtable?

I'm reading up on COM, and I'd find this information useful.

btw: Anybody interested in learning more about Com might find this article interesting:

http://msdn.microsoft.com/library/defau ... 020298.asp

Posted: Tue Feb 03, 2004 12:32 am
by Fred
IUnknow is (as all other interfaces) implemented by a definition, not by the compiler itself. Basically, an interface is a structure of pointers, where each pointer points on a function. It's the famous virtual table, as you can change functions on the fly only by changing a pointer. It's an indirect function call.

Posted: Tue Feb 03, 2004 12:55 am
by GedB
Thats great. Thanks Fred.

Posted: Tue Feb 03, 2004 8:19 am
by midebor
GedB, thanks for the link !

Fred, Just one more question.

Posted: Tue Feb 10, 2004 12:02 pm
by GedB
Fred,

It seems that each Instance of an interface needs it's own VirtualTable.

Is there a specific reason why a single Virtual Table cannot be shared between all instances?

Posted: Tue Feb 10, 2004 5:44 pm
by Fred
The only reason I see is flexibilty: you can patch each object table to redirect to another function without affecting all the objects which use it. Anyway, it should work if you affect the same pointer to your own objects.

Posted: Tue Feb 10, 2004 8:03 pm
by GedB
Thanks again, Fred.