Delete a member of a structure, and remake it as a copy of something else without using new
<p>So I'm working with an API which really isn't as functional as it could be. (Quickhaptics to be specific) In order to make something that I have work, I need to delete an object within a structure, create it again, (without using new, because the constructor for the object doesn't work the way I need it to) then set it to something. </p>

<p>I'm trying to do something along the lines of</p>

<pre><code>delete data.cursor;
Cursor* data.cursor = (Cursor*)malloc(sizeof(Cursor));
data.cursor = data.cursors[index];
</code></pre>

<p>But this causes a crash(EDIT sorry, it doesn't compile is what I meant to say, but I don't understand the compiler errors)</p>

<p>Additional info: The way the API works, I need to send it a pointer to an item, which it takes initially and writes information to throughout execution. I'm trying to update the mesh on a cursor type object. It provides update functions to load in new meshes, but they are very expensive and can only run at ~3 fps. My solution is to load the objects into an array at startup, then just switch out the object that the program looks for as a cursor. </p>

<p>I'm generally new to C++, and my experience is all from sitting down and typing with no instruction, so there may be some basic C++ thing that I'm missing.</p>

<p>EDIT: Just to be clear, doing this works, just very slowly</p>

<pre><code>delete data.cursor;
data.cursor = new Cursor("filename");
</code></pre>

<p>where data.cursors[index] was declared in teh same exact way at startup</p>
