所以我正在看我的一本书中的一段 C 代码,它与使用“typedef”运算符实现抽象数据类型有关:
struct account {
char *username;
char *password;
};
struct account;
typedef struct account *Account;
谁能给我解释一下这部分的目的是什么:
struct account;
我不确定它在这里有什么用。 谢谢!
最佳答案
struct account;
看你的代码,确实没有必要。但它可以用作前向声明,当您还没有完整的定义可用,并且您正在使用 account
类型的指针并将其定义在其他地方时。
关于c - 使用 typedef 在 C 中实现抽象数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22776317/