首页 > 其他 > 详细

C/C+小记

时间:2014-07-23 22:30:27      阅读:486      评论:0      收藏:0      [点我收藏+]

1、struct与typedef struct

  struct Student{int a;int b}stu1;  //定义名为Student的结构体,及一个Student变量stu1

  struct {int a;int b;}stu1;      //只定义了一个结构体变量stu1,未定义结构体名,无法再定义其他变量

  typedef struct Student{int a;int b;}Stu1,Stu2;  //定义结构体类型为Student,别名为Stu1或Stu2,此时有三种定义相应变量的方式:

                         struct Student st;  或  Stu1 st;  或  Stu2 st;

  typedef struct{int a;int b;}Stu1,Stu2;      //未指定结构体类型名,但给了别名Stu1或Stu2,可用之定义变量

C/C+小记,布布扣,bubuko.com

C/C+小记

原文:http://www.cnblogs.com/z-sm/p/3864107.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!