Re: do need Interfaces for COM

From: Thomas Matthews (Thomas_MatthewsSpitsOnSpamBots_at_sbcglobal.net)
Date: 05/12/04


Date: Wed, 12 May 2004 13:03:19 GMT

vimal wrote:

> Hi ,
>
> I am currently learning COM using c++. Just when I completed the
> chapter about Interfaces in Dale Rogerson's Inside COM, i got a basic
> question in my mind.
> Why do we need Interfaces??

Interfaces tell how to use a component, whether that component be a
library, function, module or piece of hardware.

> Cant we achieve what Interfaces do by just exported functions?

A cleaner method is to have all the interfaces in one place and include
them where you need them. There should be no execution cost for
including unused definitions. Placing "extern" or single function
declarations around the code prompts one to ask, "why wasn't the
entire package included" or perhaps, "what other information surrounds
these definitions?"

>
> As far as i know Interfaces are nothing but placeholders for function
> pointers.

Interfaces are more than that. According to Bertand Meyer from
"Object-oriented Software Construction", there is more to an
interface than just function declarations or place holders.
Here are some attributes of an interface:
   Description
   Input list
   Output list
   Behavior
   Side-effects
   Pre-Conditions
   Post-Conditions
   Dependencies

> If this is true why not the QueryInterface function return
> the Function pointers instead of Interface pointers??

Sorry, but there is no QueryInterface in the _standard_
C++ language, which is discussed in this newsgroup. Perhaps
you meant to post to a newsgroup that deals with COM interfaces.

>
> I appreciate any light on this thought .

I would read the FAQs and welcome.txt of newsgroups before
posting to them. Searching them first before posting is
highly recommended.

>
> Thanks in advance
> Vimal

-- 
Thomas Matthews
C++ newsgroup welcome message:
          http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq:   http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
          http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
     http://www.josuttis.com  -- C++ STL Library book


Relevant Pages

  • Re: Databinding an Klasse
    ... Huber Christian wrote: ... Eine kleine Recherche in den Beiträgen der Newsgroup ... Um welches Control handelt es sich denn? ... Welche Interfaces erfordert das ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Re: Custom Data Provider for .NET
    ... you can create business classes that provide the data interfaces for ... Please reply only to the newsgroup so that others can benefit. ... "database" that consists of essentially flat files (with no relations ... interfaces I must implement?. ...
    (microsoft.public.data.ado)
  • Re: 30 amps on a 12 v rail
    ... The interfaces provided by Google and Yahoo and the like are quite ... Outlook Express has a newsgroup interface, ... you get personally offended when i call yur usenet google ...
    (alt.comp.hardware.pc-homebuilt)
  • Re: Which is best?
    ... asking about software that interfaces with the software. ... I have not participated in this newsgroup very much so to that extent it ... software that may use external devices? ... wondering if I should then make a move to C# or another language. ...
    (microsoft.public.win32.programmer.ui)
  • Re: Application crashes while releasing IMediaSeeking interface
    ... button which stops the current playback and releases all the ... interfaces. ... use smart COM pointers (see my FAQ through the link below). ...
    (microsoft.public.win32.programmer.directx.audio)