I have this code:
and i try to use Node in the friend function:Code:template <class T> class SortedList { private: struct Node { T data; Node* next; }; Node* m_head; Node* m_current; public: friend bool operator==<T>(const SortedList<T>& L1, const SortedList<T>& L2);
the compiler (g++) doesn't recognize the type, although i made this function friend... i guess it's template related, but i can't find any info on how to do it with templates...Code:template <class T> bool operator==(const SortedList<T>& L1, const SortedList<T>& L2) { SortedList<T>::Node* head1 = L1.m_head; SortedList<T>::Node* head2 = L2.m_head; while (head1 != NULL && head2 != NULL) { if (head1->data != head2->data) { return false; } head1 = head1->next; head2 = head2->next; } return (head1 == NULL && head2 == NULL); }
it just says:
anyone?Code:../sortedlist.h:163: error: ‘head1’ was not declared in this scope ../sortedlist.h:164: error: ‘head2’ was not declared in this scope



LinkBack URL
About LinkBacks


