I get the error " no match for 'operator=' in '* n->node::child = root' in the "insert" method and I don't know how to fix it. I know it has something to do with pointers and the way I initialized the array. What I want to do is is put the 'root' in the parameter of the "insert" method in an array of type node. How can I do this? Could I get some pseudo-code please? I am at a loss. Don;t have much c++ experience.

struct node{
    struct node operator=(struct node root) {
     if(this == &root){
         return *this;
    int numOfKeys;
    double* array;
    double* value;
    int count ;
    struct node *child;
    int i;
    int j;
 * Node creator
struct node* create (int keyNum){
            int size=2*keyNum;
            struct node* ptr;
            ptr->value=new double[size];
            ptr->child=new node [size];
	    return ptr;

FILE *txtFile;
node *root;
int numOfNodes=0;

struct node * insert ( int, struct node * ) ;
int setval ( int, struct node *, int *, struct node ** ) ;
struct node * search ( int, struct node *, int * ) ;
int searchnode ( int, struct node *, int * ) ;
void fillnode ( int, struct node *, struct node *, int ) ;
void split ( int, struct node *, struct node *, int, int *, struct node ** );

struct node * insert ( int val, struct node *root )
    int i ;
    struct node *c;
    int flag ;

    flag = setval ( val, root, &i, &c ) ;
    if ( flag )
        struct node *n =create(treeOrder);
        n -> count = 1 ;
        n -> value[1] = i ;
        n -> child[0] =root ;
        return n ;
    return root ;

line 24: using an uninitialized pointer ptr You have to allocate memory for it before it can be used.

line 57: child is NOT an array of pointers to structures, but an array of structures. There is a difference. In the structure you need to declare child like this: struct node** child; Notice it has two stars, not one. Then in create() method, allocate the array of pointers like this: child = new struct node*[size];

Edited 6 Years Ago by Ancient Dragon: n/a

Thanks! Could you explain to me why it needs to be an array of pointers to structures?

Because line 57 is assigning a pointer to one of the array elements. Can't do that unless child an array of pointers.

Edited 6 Years Ago by Ancient Dragon: n/a

This question has already been answered. Start a new discussion instead.