title: How to add extra data to a tree item?
body: <p>I'm trying to add extra data to a wx Tree Item using <code>wxTreeItemData</code>, but I cannot construct a <code>wxTreeItemData</code> object, because the constructor doesn't have any parameters.</p>
  <p>Here is my sample code:</p>
  <pre><code>wxTreeCtrl treeCtrl = new wxTreeCtrl(parentWindow);
  treeCtrl-&gt;AddRoot(&quot;Root&quot;);
  treeCtrl-&gt;AppendItem(root, &quot;item&quot;, -1,-1, &quot;some extra data&quot;);
  /** Signature help for inline ​​​wxTreeItemId​ ​‌​​AppendItem​(const ​​​wxTreeItemId​ &amp;​​‌parent​, const ​​​wxString​ &amp;​​‌text​, int ​​‌image​ = -1, int ​​‌selImage​ = -1, ​​​wxTreeItemData​ *​​‌data​ = (​​​wxTreeItemData​ *)0). Summary: insert a new item in as the last child of the parent. Current parameter 3 of 5: , . **/
  </code></pre>
  <p>This gives me an error:</p>
  <pre><code>E0413. no suitable conversion function from &quot;std::string&quot; to &quot;wxTreeItemData *&quot; exists  
  </code></pre>
  <p>But when I pass a <code>wxTreeItemData</code> object nothing happens, because the object is empty.</p>
  <p>The <code>wxTreeItemData</code> constructor is without any parameters!</p>
  <p>Does anyone know how to add data to a <code>wxTreeItemData</code> object?</p>
  <h2>Another try</h2>
  I declared a new class that is derived from the `wxTreeItemData` class, then added a string that will hold the data, and then, I declared, and defined a method to return the data.
  Code sample:
  <pre><code>wxTreeItemId item = treeCtrl-&gt;AppendItem(Root, &quot;item&quot;, -1,-1, new DataItem(&quot;some extra data&quot;));
  // It should set the new DataItem object as a wxTreeItemData
  // I'll try to get the data object from the TreeCtrl:
  DataItem *data = treeCtrl-&gt;GetItemData(item);
  // Signature help for virtual ​​​wxTreeItemData​ * ​‌​​GetItemData​(const ​​​wxTreeItemId​ &amp;​​‌item​) const.
  // Trying to print the data:
  std::cout &lt;&lt; data-&gt;GetData();
  // It should print the data.
  </code></pre>
  <p>Error:</p>
  <pre><code>E0144. a value of type &quot;wxTreeItemData *&quot; cannot be used to initialize an entity of type &quot;DataItem *&quot;
  </code></pre>
  <p>Because the method <code>GetItemData()</code> returns a wxTreeItemData object.
  And if I tried to replace the <code>DataItem</code> to wxTreeItemData, I cannot invoke the <code>GetData()</code> method of my DataItem object.</p>
  <h2>Helpful resources:</h2>
  [wxWidgets: wxTreeCtrl Class Reference][1]
  <p><a href="https://docs.wxwidgets.org/3.0/classwx_tree_item_data.html" rel="nofollow noreferrer">wxWidgets: wxTreeItemData Class Reference</a></p>