title: Segmentation fault on my class function
body: <p>So I'm getting a segmentation fault on my function here and I'm not sure how to correct it. Any clues as to how I would go about it?
  I'm including my classes and then the function below to give an idea of what I have.
  Thanks!</p>
  
  <pre><code>template &lt;typename T&gt;
  class Element{
  private:
    Element *next_ = nullptr;
    string name_ = "";
    T color_ = T();
  
  public:
    Element()=default;
    Element(string name, T d) : next_(nullptr), name_(name), color_(d){};
    friend ostream&amp; operator&lt;&lt;(ostream&amp; out, Element&amp; n){
  
  
      out &lt;&lt; n.name_ &lt;&lt; ":" &lt;&lt; n.color_;
      return out;
  
    }
    friend class PAL&lt;T&gt;;
  };
  
  
  template&lt;typename T&gt;
  class PAL{
  private:
    Element&lt;T&gt; *back_ = nullptr;
    Element&lt;T&gt; *front_ = nullptr;
    void print_list(ostream&amp; out);  
  public:
    PAL()=default;
    PAL(Element&lt;T&gt; n) : back_(&amp;n), front_(&amp;n) {};
    PAL(string n, T d);
    PAL(const PAL&amp;);
    PAL&amp; operator=(PAL);
    ~PAL();
    void add(Element&lt;T&gt; &amp;n);
    void add(string name, T dat);
    pair&lt;Element&lt;T&gt;*, Element&lt;T&gt;*&gt; find(string name);    
    pair&lt;Element&lt;T&gt;*, Element&lt;T&gt;*&gt; find(Element&lt;T&gt; &amp;n);
    void move_forward1(Element&lt;T&gt; &amp;n);
    void move_to_front(Element&lt;T&gt; &amp;n);  
    void move_back1(Element&lt;T&gt; &amp;n);
    void move_to_back(Element&lt;T&gt; &amp;n);  
  
    friend ostream&amp; operator&lt;&lt;(ostream&amp; out, PAL&lt;T&gt;&amp; sl){
      sl.print_list(out);
      return out;
    };
  };
  
  template&lt;typename T&gt;
  pair&lt;Element&lt;T&gt;*, Element&lt;T&gt;*&gt; PAL&lt;T&gt;::find(string name){
      pair&lt;Element&lt;T&gt;*, Element&lt;T&gt;*&gt; *result (nullptr);
      Element&lt;T&gt;* x = nullptr;
      Element&lt;T&gt;* y = nullptr;
      for (Element&lt;T&gt; *n = back_; n != nullptr; n = n -&gt; next_){
          if (n -&gt; name_ == name){
              x = n;
              cout &lt;&lt; x;
              break;
          }
          y = n;
      }
      result -&gt; first = x;
      result -&gt; second = y;
      return *result;
  }
  </code></pre>