您的位置:首页 > 其它

struct与typedef

2015-08-25 10:26 148 查看
分下面几种情形来讲

1.struct Student{

int a;

int b;

}

在c++中,Student是一个类型,可以直接申明 这个变量进行访问,比如Student a;但在c语言中,Student是一个临时命名,不是一个类型,struct Student才是一个类型。对申明这样的一个类型需要在前面加上关键字struct。比如struct Student a;

2.typedef struct Student{

int a;

int b;

}Stu;

像这种前面添加typedef关键字的,

在c语言中, 申请这个结构变量可以:

1).struct Student a

2).Stu a;

在C++中,可以用下面这三种方式:

1).struct Student a

2).Stu a;

3)Student a
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: