Chapter 4, “Objects in ATL,” discussed how ATL implements
IUnknown, but it covered only
Release completely. This chapter takes a look first at the requirements that COM makes on an object’s implementation of
QueryInterface and then at how ATL supports those requirements while still providing flexibility and extensibility.
From a client perspective, the rules of
Release are fairly stringent. Unless the client is careful about their use, objects can go away before expected or can stay around too long. However, the object is allowed to implement
Release in any number of ways, depending on how it wants to manage its own lifetime—for example, as a heap-based, stack-based, ...