C++ LinkList and Node Template Linking Errors -


i trying create node template use linked list template getting error constructors in node.h not defined. have node.h file , node.tem file created in visual studio. node.h file looks this:

#ifndef node_h #define node_h  #include <cstdlib>  template <class type> class node { public:     node();     node(type indata);      type data;     node<type>* next;     node<type>* prev;  }; #include "node.tem" #endif 

and node.tem file looks this:

template <class type> node<type>::node() {     next = nullptr; }  template <class type> node<type>::node(type indata) {     data = indata;     next = nullptr; } 

after debugging, looks problem occurs in alloc function in linked list template on bit of code:

template <class type> node<type>* linklist<type>::alloc(type indata) {     node<type>* dynamicnode = new node(indata); //error occurs here     return dynamicnode; } 

the errors are:

'node': class has no constructors , 'node': use of class template requires template argument list

my main() code rather large small piece of big project, can post if needed.

i think forgot <type> in new node:

node<type>* dynamicnode = new node<type>(indata);  

also, best use auto:

auto dynamicnode = new node<type>(indata);  

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -