Note that there are some explanatory texts on larger screens.

plurals
  1. POimplementing a copy constructor
    primarykey
    data
    text
    <p>I have the following class definition and it needs a copy constructor so deep copies are made to copy the raw pointers. Can anybody advice on how to best do this?</p> <p>Using <a href="http://xerces.apache.org/xerces-c/apiDocs-3/index.html" rel="nofollow">xerces-c++</a> for XML</p> <pre><code>class XMLDocument { private: typedef std::vector&lt;XML::XMLNode&gt; v_nodes; public: XMLDocument::XMLDocument(); XMLDocument::XMLDocument(const XMLDocument&amp; copy); XMLDocument::~XMLDocument(); XMLDocument&amp; operator=(XMLDocument const&amp; rhs); void CreateDocument(const std::string&amp; docname); void AddChildNode(XMLNode&amp; node); void RemoveNode(XMLNode&amp; node); void AddNodeValue(XMLNode&amp; node, const std::string&amp; value); void AddNodeValue(XMLNode&amp; node, int value); void AddNodeValue(XMLNode&amp; node, double value); void AddNodeValue(XMLNode&amp; node, float value); std::string GetXMLAttributes(); std::string GetXMLAttribute(const std::string&amp; attrib); std::string GetXMLNodeText(XML::XMLNode&amp; node); std::string DumpToString(); XMLNode GetXPathNode(const std::string xpathXpression); XMLNode GetNode(const XMLNode &amp;currentnode); typedef v_nodes::iterator nodes_iterator; nodes_iterator begin() { nodes_iterator iter; iter = xmlnodes.begin(); return iter; } nodes_iterator end() { nodes_iterator iter; iter = xmlnodes.end(); return iter; } private: v_nodes xmlnodes; bool InitializeXML(); DOMImplementation* impl; //Abstract DOMDocument* document; //Abstract DOMElement* rootelement; //Abstract }; </code></pre> <p>The DOMDocument <strong>is created calling a function</strong> and <strong>so is</strong> the DOMElement. So I can't just call new on these pointers.</p> <p>Not sure if I just literally recreate all these object?</p> <p>Example:</p> <pre><code>document = impl-&gt;createDocument(0, "mydoc", 0); </code></pre> <p>Who's gone on a downvote rage and not given a reason???</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload