CComObject
ATL / WTL / STL
2
Posts
2
Posters
0
Views
1
Watching
-
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
It's because of the
IUnknown
'sAddRef
,Release
andQueryInterface
implementation. You have to achieve, that theIUnknown
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 theCComObject
is a neat trick, how to save user the need to write theAddRef/Release
code into every user class.