i did more digging and now i'm very confused....haha...
both of the following versions will not throw the memory access violation anymore.
version A:
Code:
int main()
{
::CoInitialize(NULL);
MSXML2::IXMLDOMDocumentPtr doc;
doc.CreateInstance(__uuidof(MSXML2::DOMDocument));
doc.Release();
::CoUninitialize();
}
version B:
Code:
class CXmlDocument
{
private:
MSXML2::IXMLDOMDocumentPtr mp_Document;
public:
CXmlDocument()
{
::CoInitialize(NULL);
mp_Document.CreateInstance(__uuidof(MSXML2::DOMDocument));
}
~CXmlDocument()
{
mp_Document = 0;
::CoUninitialize();
}
MSXML2::IXMLDOMDocumentPtr operator->() { return mp_Document; }
};
int main()
{
CXmlDocument doc;
}
if i use Release() in CXmlDocument's destructor, i will get a memory access violation. can someone please explain what's happening? i just want to make sure i understand so there's no memory leaks due to my ignorance. thanks.