说明一下:BST_TREE * BST_Create(int(* compare)(void * argu1,void * argu2));

时间:2018-11-21 17:22:44

标签: c

我不明白这个论点,这是我第一次看到它。

下面是结构:

typedef struct node{
void* dataPtr;
struct node* left;
struct node* right;
}NODE;

typedef struct{
    int count;
    int (*compare)(void* argu1, void* argu2);
    NODE* root;
}BST_TREE;

这是原型:

BST_TREE* BST_Create(int (*compare)(void* argu1, void* argu2));

这是功能:

BST_TREE* BST_Create(int (*compare)(void* argu1, void *argu2)){
    BST_TREE* tree;
    tree = (BST_TREE*)malloc(sizeof(BST_TREE));
    if(tree){
        tree->root = NULL;
        tree->count = 0;
        tree->compare = compare;
    }
    return tree;
}

0 个答案:

没有答案