Mình tìm mãi vẫn ko hiểu vì sao lỗi trc mình dùng visual studio để code thì ko sao nhưng chuyển qua dev-c thì lại bị lỗi này :(( đây là code của mình.
#include <iostream>
using namespace std;
class Node {
int data;
Node* next;
Node* prev;
Node() {
}
Node(int data) {
this->data = data;
next = NULL;
prev = NULL;
}
friend class List;
};
class List {
Node* head;
Node* tail;
public:
List() {
head = NULL;
tail = NULL;
}
void addLast(int data) {
Node* newNode = new Node;
newNode->data = data;
if (head == NULL) {
head = newNode;
tail = newNode;
}
else {
newNode->prev = tail;
tail->next = newNode;
tail = newNode;
}
}
void printAll() {
Node* p = head;
while (p != NULL) {
cout << p->data << " ";
p = p->next;
}
}
};
int main() {
List list;
list.addLast(5);
list.addLast(6);
list.addLast(7);
list.printAll();
return 0;
}