This code snippet is an example I saw online:
struct Node {
int data;
Node* Left;
Node* Right;
}
Node* CreateNode(int data) {
Node* newNode = new Node();
newNode->data = data;
newNode->Left = newNode->Right = nullptr;
return newNode;
}
I cannot understand, why are the nodes inside using pointers, instead of just simply the nodes themselves?
And also, why is the function for creating nodes returning a pointer?