Need for ClassFactory.
-
What is the need of ClassFactory ? I mean The interface pointer can be obtained by using CoCreateInstance, then why to use CoGetClassObject.
CocreateInstance in used to obtain only single Object of the class. Whilei CoGetClassObject is used to obtain the multiple Object of the same Class. And CocreateInstance automatically call the ClassFactory(). you don't have to care for it.
-
What is the need of ClassFactory ? I mean The interface pointer can be obtained by using CoCreateInstance, then why to use CoGetClassObject.
Firstly, as already mentioned,
CoCreateInstance
uses theIClassFactory
interface to create the object. Secondly,IClassFactory
has other methods besidesCreateInstance
. Finally, the class factory is allowed to implement other interfaces.Steve