Hello everyone i wish you are having a great day, i have a problem with allocation memory for my tree with some code i think it's easier to explain and understand.
 #define H 7
 class Node{
    public:
         int node_number;
         int depth;
         int value;
         Node* nodes[L];
    public:
         Node new_node(int node_number,int depth,int value);
         void  add_node(Node root_node,Node new_node);
         void  print_node(Node print_node);
};
To create a node my function is here
Node Node::new_node(int node_number,int depth,int value){
    Node x;
    x.node_number=node_number;
    x.depth=depth;
    x.value=value;
    x.nodes[L]=(Node*) std::malloc(L*sizeof(Node));
    return x; 
 }
and now when i want to add nodes in the node him self like declared in the class i got Segmentation fault (core dumped)
void Node::add_node(Node root_node,Node new_node){
    root_node.nodes[0]=&(new_node);
}
My main function
Node root_node;
root_node=root_node.new_node(10,2,23);
Node x;
x=x.new_node(17,19,7);
root_node.add_node(root_node,x);
root_node.print_node(root_node);
Thank you so much
 
     
    