title: My program is segmentation faulting but it ran before I implemented polymorphism
body: <p>This my program that let you add a student or a faculty person into a list. Whenever the function addHead() and addTail() is called the program would crash after line 307 or 325</p>
  <p>this is the base class</p>
  <pre><code>class Person
   {
      private:
          string name, title, department;
      public:
          Person *next, *prev;
          // Constructor &amp; Destructor
          Person()
          {
              name = &quot;&quot;;
              title = &quot;&quot;;
              department = &quot;&quot;;
          }
  
          Person(string nName, string nTitle, string nDepartment)
          {
              name = nName;
              title = nTitle;
              department = nDepartment;
          }
  
          ~Person(){};
  
          // Setters
          void setName(string nName)
          {
              name = nName;
          }
  
          void setTitle(string nTitle)
          {
              title = nTitle;
          }
          void setDepartment(string nDepartment)
          {
              department = nDepartment;
          }
  
          // get-ers
          string getName()
          {
              return name;
          }
  
          string getTitle()
          {
              return title;
          }
  
          string getDepartment()
          {
              return department;
          }
  
          virtual void printAll()
          {
              printf(&quot;%s is a %s in the %s department \n&quot;, name.data(), title.data(), department.data());
          }
  
  };
  </code></pre>
  <p>This is the 2 derived class</p>
  <pre><code>class Student: public Person{
      private:
          struct Date gradDay;
          string minor, extraC;
  
      public:
      
          Student(string nName, string nTitle, string nDepartment, int m, int d, int y, string nMinor, string nExtraC)
              : Person(nName,nTitle,nDepartment)
          {
              gradDay.month = m;
              gradDay.day = d;
              gradDay.year = y;
              minor = nMinor;
              extraC = nExtraC;
          }
          ~Student(){};
  
          // Setters
          void setDate(int m, int d, int y)
          {
              gradDay.month = m;
              gradDay.day = d;
              gradDay.year = y;
          }
  
          void setMinor(string nMinor)
          {
              minor = nMinor;
          }
  
          void setExtraC(string nExtraC)
          {
              extraC = nExtraC;
          }
  
          // Getters
          Date getDate()
          {
              return gradDay;
          }
  
          string getMinor()
          {
              return minor;
          }
  
          string getExtraC()
          {
              return extraC;
          }
  
          // This function finds the number of months until graduation
          int monthTilGrad(int month, int year)
          {
              int x = month + year*12;
              int y = gradDay.month + gradDay.year*12;
  
              return y - x;
          }
  
          void printAll()
          {
              Person::printAll();
              printf(&quot;     They minor in %s and will graduate on %d/%d/%d. \n     Extracurricular Activities: %s\n&quot;,minor.data(), gradDay.month, gradDay.day, gradDay.year, extraC.data());
          }
  
  };
  
  class Faculty: public Person{
      private:
          Date startDate;
      public:
          Faculty(string nName, string nTitle, string nDepartment, int m, int d, int y)
              : Person(nName,nTitle,nDepartment)
          {
              startDate.month = m;
              startDate.day = d;
              startDate.year = y;
          }
  
          ~Faculty(){};
  
          // Setters
          void setStartDate(int m, int d, int y)
          {
              startDate.month = m;
              startDate.day = d;
              startDate.year = y;
          }
          
          // Getters
          Date getStartDate(){
              return startDate;
          }
  
          void printAll()
          {   
              Person::printAll();
              printf(&quot;     They started working here on %d/%d/%d\n&quot;, startDate.month, startDate.day, startDate.year);
          }
  };
  </code></pre>
  <p>This is the list that I made</p>
  <pre><code>class list_c{
      protected:
          Person *Head, *Tail;
      public:
          void addHead(string nName, string nTitle, string nDepartment, int m, int d, int y, string nMinor, string nExtraC);
          void addTail(string nName, string nTitle, string nDepartment, int m, int d, int y);
          void remove(string name);
          void deleteAll();
          void search(string name);
          void printAll();
  };
  </code></pre>
  <p>These 2 functions are the problematic ones. they're suppose to add a new student object to the head of the doublylinked list and a faculty object to the tail of the list</p>
  <pre><code>
  void list_c::addHead(string nName, string nTitle, string nDepartment, int m, int d, int y, string nMinor, string nExtraC)
  {     
      cout&lt;&lt;&quot;in addHead()\n&quot;;
      Person *newStudent = new Student(nName,nTitle,nDepartment,m,d,y,nMinor,nExtraC);
  
      cout&lt;&lt;&quot;before iff\n&quot;;
      if(Head)
      {
          Head = newStudent;
  
      } else{
          cout &lt;&lt; &quot;in else\n&quot;;
          Head-&gt;prev = newStudent;
          newStudent-&gt;next = Head;
          Head = newStudent;
          Head-&gt;prev = NULL;
          cout &lt;&lt; &quot;end of else\n&quot;;
      }
  
      cout&lt;&lt;&quot;exiting addHead()...\n&quot;;
  }
  
  void list_c::addTail(string nName, string nTitle, string nDepartment,int m, int d, int y)
  {   
      Person *newPerson = new Faculty(nName,nTitle,nDepartment,m,d,y);
      if(Tail == NULL)
      {
          Tail = newPerson;
  
      } else{
          Tail-&gt;next = newPerson;
          newPerson-&gt;prev = Tail;
          Tail = newPerson;
          Tail-&gt;next = NULL;
      }
  }
  </code></pre>
  <p>Thank in advance y'all!!</p>