do need Interfaces for COM

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vimal

    do need Interfaces for COM

    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?? Cant we achieve what Interfaces do by just
    exported functions?

    As far as i know Interfaces are nothing but placeholders for function
    pointers. If this is true why not the QueryInterface function return
    the Function pointers instead of Interface pointers??

    I appreciate any light on this thought .

    Thanks in advance
    Vimal
  • Thomas Matthews

    #2
    Re: do need Interfaces for COM

    vimal wrote:
    [color=blue]
    > 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??[/color]

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

    [color=blue]
    > Cant we achieve what Interfaces do by just exported functions?[/color]

    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?"

    [color=blue]
    >
    > As far as i know Interfaces are nothing but placeholders for function
    > pointers.[/color]

    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

    [color=blue]
    > If this is true why not the QueryInterface function return
    > the Function pointers instead of Interface pointers??[/color]

    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.

    [color=blue]
    >
    > I appreciate any light on this thought .[/color]

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

    [color=blue]
    >
    > Thanks in advance
    > Vimal[/color]


    --
    Thomas Matthews

    C++ newsgroup welcome message:

    C++ Faq: http://www.parashift.com/c++-faq-lite
    C Faq: http://www.eskimo.com/~scs/c-faq/top.html
    alt.comp.lang.l earn.c-c++ faq:

    Other sites:
    http://www.josuttis.com -- C++ STL Library book

    Comment

    Working...