ATL COM objects - Quiz Explanation
The correct answers are indicated below, along with the text that explains the correct answers.
1.
Every ATL-based COM object implemented within a server:
Please select the best answer.
A.
Has an object map entry
B.
Must have
obj
in its name
C.
Uses the same CLSID
The correct answer is A.
An object map binds a C++ class that implements a COM object into the ATL framework.
2.
In ATL, COM object implementation classes:
Please select the best answer.
A.
Inherit from
CComObject
B.
Implement
IUnknown
C.
Multiply inherit from each interface they implement as well as
CComObjectRoot
and
CComCoClass
The correct answer is C.
ATL uses multiple inheritance of interface specifications, i.e., each interface implemented by an ATL-based COM object is defined as a C++ class with all pure virtual methods.
3.
In COM, inheriting from an interface means:
Please select the best answer.
A.
The derived class must implement all functions in the interface in any order.
B.
The derived class does not have to implement the interface functions because we inherit them from the base class.
C.
The derived class must implement all functions in the interface in
vtable
order.
The correct answer is C.
COM does not support implementation inheritance. Inheritance, when applied to COM, means inherit a specification.
4.
An ATL-based COM object implementation class must:
Please select the best answer.
A.
Implement
IUnknown
B.
Have a COM map that contains an entry for each COM interface it implements
C.
Have an object map for each method in its interfaces
The correct answer is B.
Each interface implemented by an ATL-based COM object must be entered into a COM map to bind it into the ATL framework. Our ATL-based COM classes do not implement
IUnknown
; derived class
CComObject
implements
IUnknown
.