I'm working on an assignment for an introductory C++ course and am trying to make the compiler happy, but everything I've done so far throws some sort of error. An error is being thrown with the following code:
friend void make_LinkedList(template <class T>LinkedList<T> &list, node *root);
This is inside the definition of the class tree which has a private struct node. LinkedList is a templated class. This function is meant to convert a tree to a linked list. Basically, I need to have the function accept a node pointer and a LinkedList object as arguments. LinkedList is templated, though, and I can neither find nor figure out the syntax for defining a function that accepts a templated class object that's defined in a different header file. Please let me know if I've left anything out. Any help is appreciated
You should move the template <class T>
before the method definition:
template <class T>
friend void make_LinkedList(LinkedList<T> &list, node *root);