title: Printing Double Linked List
body: <p>So I'm a bloody idiot and cannot for the life of me figure this out. This is after a few hours of looking for a possible answer to no avail. I'm required to have the overloaded &lt;&lt; operator to pass to a print function within a class. My current implementation is an allegedly working example that gives me the following error:</p>
  
  <pre><code>List.cpp:261:55: error: default argument given for parameter 2 of ‘void cop4530::
  List&lt;T&gt;::print(std::ostream&amp;, char) const’ [-fpermissive] In file included from
  test_list.cpp:3:0: List.h:103:10: error: after previous specification in ‘void
  cop4530::List&lt;T&gt;::print(std::ostream&amp;, char) const’ [-fpermissive]
  </code></pre>
  
  <p>I would greatly appreciate any help with this as it's my last ducking error. </p>
  
  <p>Here is the Implementation File:</p>
  
  <pre><code>template &lt;class T&gt;
  void List&lt;T&gt;::print(std::ostream&amp; os, char ofc = ' ') const {
  
      for (List&lt;T&gt;::const_iterator it = begin(); it != end(); ++it)
      { 
           os &lt;&lt; *it &lt;&lt; ofc;
      }
  }
  
  template &lt;class T&gt;
  std::ostream &amp; operator&lt;&lt;(std::ostream &amp;os, const List&lt;T&gt; &amp;l) {
      l.print(os);
      return os;
  }
  </code></pre>
  
  <p>Here is the header file:</p>
  
  <pre><code>#ifndef DL_LIST_H
  #define DL_LIST_H
  #include &lt;iostream&gt;
  
  namespace cop4530 {
  
  template &lt;typename T&gt;
  class List {
   private:
      // nested Node class
      struct Node {
          T data;
          Node *prev;
          Node *next;
  
          Node(const T &amp; d = T{}, Node *p = nullptr, Node *n = nullptr) 
              : data{d}, prev{p}, next{n} {}
          Node(T &amp;&amp; d, Node *p = nullptr, Node *n = nullptr)
              : data{std::move(d)}, prev{p}, next{n} {}
      };
  
   public:
      //nested const_iterator class
      class const_iterator {
      public:
      const_iterator(); // default zero parameter constructor
      const T &amp; operator*() const; // operator*() to return element
  
      // increment/decrement operators
      const_iterator &amp; operator++();
      const_iterator operator++(int);
      const_iterator &amp; operator--();
      const_iterator operator--(int);
  
      // comparison operators
      bool operator==(const const_iterator &amp;rhs) const;
      bool operator!=(const const_iterator &amp;rhs) const;
  
      protected:
      Node *current; // pointer to node in List
      T &amp; retrieve() const; // retrieve the element refers to
      const_iterator(Node *p); // protected constructor
  
      friend class List&lt;T&gt;;
      };
  
      // nested iterator class
      class iterator : public const_iterator {
      public:
      iterator() {}
      T &amp; operator*();
      const T &amp; operator*() const;
  
      // increment/decrement operators
      iterator &amp; operator++();
      iterator operator++(int);
      iterator &amp; operator--();
      iterator operator--(int);
  
      protected:
      iterator(Node *p);
      friend class List&lt;T&gt;;
      };
  
   public:
      // constructor, desctructor, copy constructor
      List(); // default zero parameter constructor
      List(const List &amp;rhs); // copy constructor
      List(List &amp;&amp; rhs); // move constructor
      // num elements with value of val
      explicit List(int num, const T&amp; val = T{}); 
      // constructs with elements [start, end)
      List(const_iterator start, const_iterator end); 
  
      ~List(); // destructor
  
      // copy assignment operator
      const List&amp; operator=(const List &amp;rhs);
      // move assignment operator
      List &amp; operator=(List &amp;&amp; rhs);
  
      // member functions
      int size() const; // number of elements
      bool empty() const; // check if list is empty
      void clear(); // delete all elements
      void reverse(); // reverse the order of the elements
  
      T &amp;front(); // reference to the first element
      const T&amp; front() const;
      T &amp;back(); // reference to the last element
      const T &amp; back() const; 
  
      void push_front(const T &amp; val); // insert to the beginning
      void push_front(T &amp;&amp; val); // move version of insert
      void push_back(const T &amp; val); // insert to the end
      void push_back(T &amp;&amp; val); // move version of insert
      void pop_front(); // delete first element
      void pop_back(); // delete last element
  
      void remove(const T &amp;val); // remove all elements with value = val
  
      // print out all elements. ofc is deliminitor
      void print(std::ostream&amp; os, char ofc = ' ') const; 
  
      iterator begin(); // iterator to first element
      const_iterator begin() const;
      iterator end(); // end marker iterator
      const_iterator end() const; 
      iterator insert(iterator itr, const T&amp; val); // insert val ahead of itr
      iterator insert(iterator itr, T &amp;&amp; val); // move version of insert
      iterator erase(iterator itr); // erase one element
      iterator erase(iterator start, iterator end); // erase [start, end)
  
  
  private:
      int theSize; // number of elements
      Node *head; // head node
      Node *tail; // tail node
  
      void init(); // initialization
  };
  
  // overloading comparison operators
  template &lt;typename T&gt;
  bool operator==(const List&lt;T&gt; &amp; lhs, const List&lt;T&gt; &amp;rhs);
  
  template &lt;typename T&gt;
  bool operator!=(const List&lt;T&gt; &amp; lhs, const List&lt;T&gt; &amp;rhs);
  
  // overloading output operator
  template &lt;typename T&gt;
  std::ostream &amp; operator&lt;&lt;(std::ostream &amp;os, const List&lt;T&gt; &amp;l);
  
  // include the implementation file here
  #include "List.cpp"
  
  } // end of namespace 4530
  
  #endif
  </code></pre>