typedef struct hash_table_data
{
int key;
int data;
struct hash_table_data* next;
struct hash_table_data* prev;
}hash_table_data;
typedef struct hash_table
{
int num_entries;
struct hash_table **entries;
}hash_table;
VERSUSC - 这两个结构声明有什么区别?
struct hash_table_data_
{
int key,data;
struct hash_table_data_ *next,*prev;
};
typedef struct hash_table_data_ hash_table_data;
struct hash_table_
{
int num_entries;
struct hash_table_data_ **entries;
};
typedef struct hash_table_ hash_table;
这功课吗? – Suroot
是不是第一个更好的风格? –
在我看来(这是争论)后一个例子是更好的风格;因为它不会将结构定义与typedef混合在一起。但是,有很多人觉得其他方面同样强烈。修改或扩展其他代码时最好抛弃这些意见。做他们做的事。当从头开始编写自己的新代码时,这是唯一适合对这样的话题发表看法的时候。 –