Login Register


[C++] Heap corruption detected! filter_list
Author
Message
[C++] Heap corruption detected! #1
Hi I got this error when I make a delete in a constructor and I can't figure out whyT_T
This is my class:
Code:
lass DataContainer{ public: DataContainer(){ data = NULL; valid = false; } DataContainer(const char* data1){ data = new char[strlen(data1)]; strcpy(data,data1); valid = true; } bool isValid(); const char* getData(); void setData(char* data1); ~DataContainer(){ if(valid){ delete [] data; //this is the instruction } } private: bool valid; char* data; };
It seems correct to me...

Reply







Users browsing this thread: 1 Guest(s)