I’m having trouble figuring out what’s wrong with my program. I’ve constructed it with class declarations and member function declarations in the header file, member function definitions in one .cpp file, and then I have a main driver program in main.cpp. I’ve put them all into one file on ideone so that I could post the program here:
The error shown on ideone is indeed the error my IDE shows when building. Can someone point out what I’m doing wrong?
The error is:
prog.cpp: In instantiation of ‘IntDLLNode<int>’:
prog.cpp:56: instantiated from ‘void IntDLList<T>::addToDLLHead(const T&) [with T = int]’
prog.cpp:215: instantiated from here
prog.cpp:8: error: template argument required for ‘struct IntDLList’
Line 56: head = new IntDLLNode<T>(el,head,NULL);
Line 215: dll.addToDLLHead(numero);
Line 8: class IntDLLNode {
You can ignore the try/catch clause, I haven’t finished working on that part yet — I’m just trying to get past the current error.
The problem is in the friend declaration:
Here you declare a non-template
class IntDLListto be the friend. Later, you declare a template class with the same name; but unlike you expect it will not become the friend toIntDLLNode.To fix that, specify that the friend class is a template: