Templated Linked List (Each element different type)
Posted on 2003-10-24
I am trying to create a templated linked list in C++, so I wrote this code to test whether one templated node could link to another templated node of different template type, but it gave me the error shown in comments. Any suggestions?
template <class T> Class Node
Node * next;
n1.data = 4;
n2.data = 5.22;
n1.next = &n2; // cannot convert from 'class Node<double> *' to 'class Node<int> *'