typedef和结构体的定义之间的道道

 
 
typedef struct struct_1 struct_1_t;       /*struct_1_t is a type name represent struct struct_1 */                                           
struct struct_1 {                         /*struct_1 is only name of struct*/<span style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;">		</span><span style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;">                 </span><span style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;">   </span><pre name="code" class="cpp">    int i;<span style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;">                                                                    </span>
};  /*if you want to name another same struct ,we have to write like this"struct struct_1 example1"*/                                                                                 
                                                                                     
typedef struct struct_2 {        /*It is simalar with first writing style,it's a type definition.*/                                                    
    int i;                                                                           
} struct_2_t;                                                                        
                                                                                     
typedef struct {                                                                     
    int i;                                                                           
} struct_3_t;    /*this is definition type for a struct ,struct_2_t is type name of struct*/                                                                    
                                                                                     
struct {                                                                             
    int i;                                                                           
} struct_var_4;    
                                                          
//this is basic definition,when we first to access to struct,don't you remember
<pre name="code" class="cpp">struct struct_5
{ int i; } struct_var_5; 

//of course,two position can really ha//ve same name,because of their different meaning 
//the first "same_name" is just struct'//s name,the second is one of declara//tion like struct same_name example//1
 struct same_name { int i; } same_name;
 typedef struct same_name2 { int i; } same_name2;


 
 

                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值