i have problems with distributing template. i tried with different syntax, but not a successful way with the error text:
error C2512: 'node': no appropriate default constructor available
for the code
#include<iostream>
using namespace std;
template<class t>
class node {
public:
t data;
node<t> * next;
};
template<class t>
class linkedlist {
node<t>* head;
public:
linkedlist() { head = NULL; }
bool isempty() {
return head == NULL;
}
void insertf(t value) {
node<t>* newnode = new node;
newnode->data = value;
newnode->next = NULL;
if (isempty()) {
head = newnode;
}
else {
newnode->next = head;
head = newnode;
}
}
void display() {
node<t>* tem;
tem = head;
while (tem != NULL) {
cout << tem->data<<" ";
tem = tem->next;
}
}
};
std::list(doubly linked), orstd::forward_list(singly linked)?