关于链表和指针变量的使用说明,可用于框架设计

首先定义一个链表

typedef struct Lianbiao
{
   struct Lianbiao *next;
   bool (*pFUNC)(u4,void*,void*)
   ...........
}
声明下链表
Lianbiao caonima[256];
int index = 0; 这个事链表的索引,表示到哪一个链表了;

而后写链表函数
void lianbiaohanshu()
{
    Lianbiao *pTBL;
    if(index == 256)//表示到头了
    {
        return ;
    }
    
    pTBL=&caonima[index];
    .......赋值操做
    if(index)
    {
       pTBL = &caonima[index-1];
       pTBL->next=&caonima[index];    上一表的next指向本表
    }
    index++;
}

int (*pFUNC) (int,int)
表示定义了一个指针变量指向函数 int (*)(int ,int )
如让 pFUNC = dealwithapple;
那么调用的时候,(*pFUNC)(a,b)就至关于调用
 dealwtihapple(a,b);
两个用在结构体里至关方便;
相关文章
相关标签/搜索