Thread: IUnknown

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    IUnknown

    Hello everyone,


    I am reading Unknwn.h, and the code logics is a little fuzzy. The QueryInterface, AddRef an Release are all pure virtual methods, right?


    thanks advance,
    George

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    That's right. IUnknown is part of a framework known as COM. Basically, all interfaces inherit from IUknown which means you can call any of those 3 functions on any interface (or object which inherits from those interfaces).

    AddRef() and Release() are just functions for reference counting. QueryInterface() allows you to find out what interface anything else inherits from at runtime.

    Even though COM was created by Microsoft, a lot of other people use the same principals in their framework. My company does the same thing; we have a common interface with the same 3 virtual functions.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Reading COM header files won't get you anywhere. Read a good COM tutorial instead.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks bithub and CornedBee!


    My question is answered.

    Quote Originally Posted by CornedBee View Post
    Reading COM header files won't get you anywhere. Read a good COM tutorial instead.

    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory leak in this case?
    By George2 in forum C++ Programming
    Replies: 3
    Last Post: 03-22-2008, 05:05 AM
  2. Ambiguity issue
    By George2 in forum C++ Programming
    Replies: 21
    Last Post: 02-11-2008, 12:52 AM
  3. VARIANT function or variable?
    By NewGuy100 in forum C Programming
    Replies: 7
    Last Post: 07-29-2005, 12:54 PM