Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


[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





Messages In This Thread
[C++] Heap corruption detected! - by Falcøn - 05-24-2011, 09:43 AM



Users browsing this thread: 1 Guest(s)