Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. CComObject

CComObject

Scheduled Pinned Locked Moved ATL / WTL / STL
c++question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rahulv99
    wrote on last edited by
    #1

    I know this class is the most derived class in ATL class hierarchy and (in case on non aggregatable object) is derived from user class. I want to know why is it derived from user class? regards Rahul

    G 1 Reply Last reply
    0
    • R rahulv99

      I know this class is the most derived class in ATL class hierarchy and (in case on non aggregatable object) is derived from user class. I want to know why is it derived from user class? regards Rahul

      G Offline
      G Offline
      geo_m
      wrote on last edited by
      #2

      It's because of the IUnknown's AddRef, Release and QueryInterface implementation. You have to achieve, that the IUnknown implementation is one for the whole object, regardless of how many interfaces it consists of (there's usually only one reference counter for the whole object). This means that you need the implementation to be placed in the last object in the hierarchy. Therefore the CComObject is a neat trick, how to save user the need to write the AddRef/Release code into every user class.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups