Quick question about interfaces.

Windows specific forum
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Quick question about interfaces.

Post 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
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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.
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Thats great. Thanks Fred.
midebor
User
User
Posts: 26
Joined: Fri Apr 25, 2003 10:22 pm
Location: Liege, Belgium

Post by midebor »

GedB, thanks for the link !
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Fred, Just one more question.

Post 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?
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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.
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Thanks again, Fred.
Post Reply