【发布时间】:2017-11-04 04:10:42
【问题描述】:
我在编译时不断收到此错误。我不确定我的模板构造函数是否有问题,或者我如何将类型“处理程序”插入到双向链表中。
./ListNode.h:14:3: error: constructor for 'ListNode<Handler>' must explicitly
initialize the member 'data' which does not have a default constructor
ListNode(T d);
^
./doublyLinked.h:70:25: note: in instantiation of member function
'ListNode<Handler>::ListNode' requested here
ListNode<T> *node= new ListNode<T>(d);
^
simulation.cpp:56:20: note: in instantiation of member function
'DoublyLinkedList<Handler>::insertBack' requested here
handlerList->insertBack(*handler);
^
./ListNode.h:9:5: note: member is declared here
T data;
^
./handler.h:4:7: note: 'Handler' declared here
class Handler
^
这里是完整代码的 github -> https://github.com/Cristianooo/Registrar-Simulator
【问题讨论】:
标签: c++ class templates instantiation