Вопрос по односвязным спискам
Код взял с лекции. Не могу понять почему функция creat_list типа Node и почему само название функции - указатель (*creat_list).
#include <iostream>
using namespace std;
struct Node {
int data;
Node *next;
};
Node* create_list(int n);
int main() {
setlocale(LC_ALL, "ru");
srand(time(NULL));
Node *head;
head = create_list(10);
return 0;
}
Node* create_list(int n) {
Node *head, *last, *p;
head = new Node;
head -> data = INT_MAX;
head -> next = NULL;
last = head;
for (int i = 0; i < n; i++) {
p = new Node;
p -> data = rand();
p -> next = NULL;
last -> next = p;
last = p;
}
}