課程
/后端開發(fā)
/C++
/C++遠征之離港篇
struct Coord?{??int x;??int y;?} ;
typedef struct?{??int x;??int y;?}Coord ;
2019-09-03
源自:C++遠征之離港篇 2-2
正在回答
若struct node {}這樣來定義結(jié)構(gòu)體的話。在申請node 的變量時,需要這樣寫,struct node n;若用typedef,可以這樣寫,typedef struct node{}NODE; 。在申請變量時就可以這樣寫,NODE n;區(qū)別就在于使用時,是否可以省去struct這個關(guān)鍵字。
使用typedef定義結(jié)構(gòu)體時申請使用變量就不需要加stuct
比如struct Coord{}? 申請變量時要struct Coord x;
而tyedef struct Coord{}? 申請變量時則Coord x;
區(qū)別就在于使用時,是否可以省去struct這個關(guān)鍵字。
慕姐2276339 提問者
舉報
C++掃清通往面向?qū)ο蟮淖詈笠坏勒系K,將所有知識點融會貫通
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2020-08-04
若struct node {}這樣來定義結(jié)構(gòu)體的話。在申請node 的變量時,需要這樣寫,struct node n;
若用typedef,可以這樣寫,typedef struct node{}NODE; 。在申請變量時就可以這樣寫,NODE n;
區(qū)別就在于使用時,是否可以省去struct這個關(guān)鍵字。
2019-09-04
使用typedef定義結(jié)構(gòu)體時申請使用變量就不需要加stuct
比如struct Coord{}? 申請變量時要struct Coord x;
而tyedef struct Coord{}? 申請變量時則Coord x;
區(qū)別就在于使用時,是否可以省去struct這個關(guān)鍵字。