19.05.2011, 03:11. Просмотров 2230. Ответов 16
Собственно... не шарю, как сделать двусвязный! односвязный вроде как получается. Двусвязный как-то и не очень

Конструктор:
C++ |
1
2
3
4
5
| list() {
head = NULL;
count = 0;
go_first();
} |
|
Метод класса:
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| void list::insert() {
nodes* new_node = new nodes;
char space[2] = " ";
el.InElement();
strcpy(new_node->data, el.artist); strcat(new_node->data, space);
strcat(new_node->data, el.name); strcat(new_node->data, space);
strcat(new_node->data, el.year); strcat(new_node->data, space);
strcat(new_node->data, el.price); strcat(new_node->data, space);
if(position != NULL) {
if(count == 1)
positionPrev = head;
new_node->next = position->next;
position->next = new_node;
new_node->prev = position->prev;
go_next();
} else {
position = head = new_node;
positionPrev = position->prev;
}
count++;
} |
|
что не так? делаю?