K
Kieran Simpson
In my project I have a class which I create an instance of, into a pointer
using the 'new' keyword.
Inside 'class1' I allocate memory (using malloc) for a string in the
constructor and everything works fine. When I try to destroy the instance
using the corresponding 'delete' keyword, the code goes to 'class1'
destructor where I try to free the memory (using free) allocated by the
constructor. However I get a debug error.
Am I getting the error because when I destroy the instance of 'class1' the
memory allocated by the constructor is already freed, and therefore I am
trying to free free memory, or is there something else at work?
using the 'new' keyword.
Inside 'class1' I allocate memory (using malloc) for a string in the
constructor and everything works fine. When I try to destroy the instance
using the corresponding 'delete' keyword, the code goes to 'class1'
destructor where I try to free the memory (using free) allocated by the
constructor. However I get a debug error.
Am I getting the error because when I destroy the instance of 'class1' the
memory allocated by the constructor is already freed, and therefore I am
trying to free free memory, or is there something else at work?