【专业技术】如何写出优美的C 代码? - 腾讯云开发者社区-腾讯云

PHOTO EMBED

Tue Dec 06 2022 06:12:17 GMT+0000 (Coordinated Universal Time)

Saved by @leawoliu #javascript

Node *node = NULL; 
List *list = NULL; 
 
void insert(void *node); 
void drop(void *node); 
void clear(); 
int getSize(); 
void print(); 
void* get(int index); 
 
List *ListConstruction(){ 
   list = (List*)malloc(sizeof(List)); 
   node = (Node*)malloc(sizeof(Node)); 
   list->head = node; 
   list->insert = insert;// 将 insert 函数实现注册在 list 实体上
   list->drop = drop; 
   list->clear = clear; 
   list->size = 0; 
   list->getSize = getSize; 
   list->get = get; 
   list->print = print; 
   list->_this = list;// 用 _this 指针将 list 本身保存起来
 
   return (List*)list; 
}
content_copyCOPY

构造

https://cloud.tencent.com/developer/article/1062995