Search code examples
c++c++builderdelete-operatortxmldocument

deleting TXMLDocument object Embarcadero


I've got an object to delete:

XMLDoc = new TXMLDocument(NULL);  

but I have no idea how to do that... it's not working:

delete XMLDoc;
XMLDoc->free();

When I try just delete object the program crashes.

So it's a piece of my code. I've got a class:

class C_XMLhandler{
    private:
        TXMLDocument *XMLDoc;
...
...
    public:
        void loadXMLfile(String name);
...
...
};

and example declaration of method:
bool C_XMLhandler::loadXMLfile(String name)
{
        XMLDoc = new TXMLDocument(NULL);
        Box=GetMagicBox(XMLDoc); //it's XML parser method, and it's doesen't matter
        delete XMLDoc; //when i reach this line the program scrashes
}

Solution

  • http://docwiki.embarcadero.com/Libraries/XE6/en/Xml.XMLDoc.TXMLDocument.Destroy

    The object is deleted by the component it is connected to new (this) otherwise not really sure, I read somewhere that it is auto deleted. (hmmm)