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.
I'm trying to do something along the lines of
delete data.cursor;
Cursor* data.cursor = (Cursor*)malloc(sizeof(Cursor));
data.cursor = data.cursors[index];
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)
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.
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.
EDIT: Just to be clear, doing this works, just very slowly
delete data.cursor;
data.cursor = new Cursor("filename");
where data.cursors[index] was declared in teh same exact way at startup