C++ 中“struct”和“typedef struct”有什麼區別?


在 C++ 中,“struct”和“typedef struct”沒有區別,因為在 C++ 中,只要名稱不被具有相同名稱的其他宣告隱藏,所有 struct/union/enum/class 宣告都像它們被隱式 typedef’ed 一樣。

不過有一個細微的區別,就是不能對型別定義進行前向宣告。因此,對於 typedef 選項,你必須在任何地方使用之前包含包含該 typedef 的檔案。


更新於: 2019 年 7 月 30 日

817 次檢視

職業一觸即發

完成課程獲得認證

開始學習
廣告
© . All rights reserved.