Note that there are some explanatory texts on larger screens.

plurals
  1. POHEAP CORRUPTION DETECTED: after Normal block(#151) at 0x00DB4E70
    primarykey
    data
    text
    <p>I have implemented a List for my class Word, and have HEAP CORRUPTION DETECTED, when program trying to delete my List. It goes into loop in destructor and delete first element, then when he goes second time, and trying to destroy "new" head I get Heap Corruption Error. I don't understand why it's going wrong. Any help would be much appreciated.</p> <p><strong>Word.h:</strong></p> <pre><code>#include &lt;cstring&gt; class Word { protected: char* word; char* type; public: Word(); Word(char ); Word(char *); Word(char *, int); Word(const Word&amp;); Word&amp; operator=(const Word &amp;); void setWord(char); void setWord(char *); void setWord(char*, int); void setType(char); void setType(char*); void setType(char*, int); ~Word(); }; </code></pre> <p><strong>WordList.h:</strong></p> <pre><code>#include "Word.h" #include &lt;cstdlib&gt; class WordList { public: struct Node { Word data; Node *next, *prev; //~Node(); }; Node *head; Node *tail; WordList(); ~WordList(); void add(Word &amp;d); }; </code></pre> <p><strong>WordList.cpp:</strong></p> <pre><code>#include "WordList.h" WordList::WordList(void) { head = nullptr; tail = nullptr; } WordList::~WordList(void) { while(head != nullptr) { Node *n = head-&gt;prev; delete head; head = n; } } void WordList::add(Word &amp;d) { Node *n = new Node; n-&gt;data = d; // I overload =, and it copies information from d to data n-&gt;next = head; if (head!=nullptr) head-&gt;prev = n; if(head == nullptr){ head = n; tail = head; } else head = n; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload