I am working on a board based game like checkers. Every tile on the board has certain properties. Before changing the board status, I want to save it’s state and use it to undo the last move. As the status changes, all objects are destructed and new ones are created. Is there any way to retain these pointers as well as calling the destructor?
Share
You do not want to retain the pointer in this way. If you attempt to access the data through those pointers AFTER they have been deleted, you will get access violations. Once they are deleted the memory they point to should not be accessed through those pointers.
If you take copies of these pointers, they will also have the same address, so accessing that memory through the copies you take will result in the same thing happening. You need to consider a different approach