---
# System prepended metadata

title: Tree struct example

---

# Tree struct example

```cpp=
#include<stdio.h>
#include<vector>

using namespace std;

typedef struct node {
    int value;
    vector<struct node*> children;
} Node;

int main() {
    Node* root = new Node();
    root->value = 1;
    Node* node2 = new Node();
    Node* node3 = new Node();
    node2->value = 2;
    node3->value = 3;
    root->children.push_back(node2);
    root->children.push_back(node3);

    printf("%d %d %d\n", root->value, root->children[0]->value, root->children[1]->value);

    return 0;
}


```