使用 typedef 宣告多個型別
typedef
關鍵字是一個說明符,因此它分別應用於每個宣告符。因此,宣告的每個名稱都指的是在沒有 typedef
的情況下該名稱所具有的型別。
int *x, (*p)(); // x has type int*, and p has type int(*)()
typedef int *x, (*p)(); // x is an alias for int*, while p is an alias for int(*)()
typedef
關鍵字是一個說明符,因此它分別應用於每個宣告符。因此,宣告的每個名稱都指的是在沒有 typedef
的情況下該名稱所具有的型別。
int *x, (*p)(); // x has type int*, and p has type int(*)()
typedef int *x, (*p)(); // x is an alias for int*, while p is an alias for int(*)()