couldn't find the reason why am I getting the following warning:
simple_list.h:36:69: warning: friend declaration ‘std::ostream& operator<<(std::ostream&, const list<Elem>&)’ declares a non-template function [-Wnon-template-friend] 36 | friend std::ostream &operator<<(std::ostream &os, const list <); | ^ simple_list.h:36:69: note: (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here)
I have declared the friend function in the header file as shown below
#include <iostream>
#include <limits>
template<typename Elem>
struct Link {
Link* succ;// successor (next) link
Elem val;// the value
};
template<typename Elem>
class list {
private:
unsigned int lsize;
Link<Elem>* first;
Link<Elem>* last; // one beyond the last link
public:
class iterator;
list();
list &operator=(const list &obj);
bool empty();
unsigned int size();
iterator begin();
iterator end();
iterator insert_after(iterator p, const Elem &v);
iterator erase_after(iterator p);
// void push_back(const Elem& v);
void push_front(const Elem &v);
// void pop_front();
// void pop_back();
Elem &front();
// Elem& back();
unsigned int max_size();
friend std::ostream &operator<<(std::ostream &os, const list <);
~list();
};