First one is a Smart Pointer and the Second one is a normal pointer.
You don't need to worry about Releasing
a Smart Pointer whereas you have to explicitly Release()
a normal COM Interface Pointer.
For more details on Smart Pointers, Look Here
Apart from that, the first one will try to find a GUID from registry for your Class named TestClass
and will try to create an Instance of this class through CoCreateInstance
API Call. It will try to get the IDiscover
interface pointer through the said CoCreateInstance
call and will throw an error if it fails to do so. On successful execution of the line IDiscoverPtr id(__uuid(TestClass));
, you should have a valid IDiscover
interface pointer in id
.
The Second one is simply declaration of an Interface pointer, nothing else. You will have to instantiate it yourself through (most of the times) CoCreateInstance
or one of it's variants.