I have created a class like this:
class TEST{
private:
TEST *sptr;
public:
TEST(TEST *);
void Release(void);
};
void CreateClass(TEST *&test){
test=new TEST(test);
};
It is like creating objects in DirectX but there is one problem:
TEST::TEST(TEST *tptr){
sptr=tptr;
};
void TEST::Release(void){
delete(sptr);
};
The problem is that it just deletes the class before it can exit from the function giving a memory access violation. This the way I would solve it in assembler:
-Saving the instruction pointer before you enter the Release member function.
-In release save the old instruction pointer, the object pointer (sptr) and the object type on the stack and jump to another function.
-Then delete the object and jump to the place where you called the Release member function.
Anyone has an idea how to do this in C++?
Sludge Software
www.sludgesoft.com
Developing a secret of mana style role-playing-game