title: Segmentation Fault C++
body: <p>I am getting a "Segmentation fault (core dumped)" run-time error with the following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Student.h"
  #include "SortedList.h"
  
  using namespace std;
  
  #define BOUNDS 100
  
  int main() {
  
      SortedList *list = new SortedList();  // points to the sorted list object
      Student *create[BOUNDS];  // array to hold 100 student objects
      int num = 100000;   // holds different ID numbers
  
      // fills an array with 100 students of various ID numbers
      for (int i = 0; i &lt; BOUNDS; i++) {
          create[i] = new Student(num);
          num += 10;
      }
  
      // insert all students into the sorted list
      for (int i = 0; i &lt; BOUNDS; i++)
      list-&gt;insert(create[i]);
  
      // individually deletes each student
      num = 100000;
      for (int i = 0; i &lt; BOUNDS; i++) {
          delete list-&gt;find(num);
      num += 10;
      }
  
      // insert all students into the sorted list
      for (int i = 0; i &lt; BOUNDS; i++)
      list-&gt;insert(create[i]);
  
      num = 100000;
      for (int i = 0; i &lt; BOUNDS; i++) {
      list-&gt;remove(num);
      num += 10;
      }
  
      cout &lt;&lt; "test2" &lt;&lt; endl;
      delete list;
      return 0;
  }
  </code></pre>
  
  <p>I have narrowed the error down to the <code>delete list;</code> lines (or whichever one comes first). I am just wondering as to why this is and how to possibly fix it. Any insight on this matter would be useful.</p>