struct和typedef struct用法
2015-11-29 00:08
309 查看
参考:http://www.cnblogs.com/qyaizs/articles/2039101.html
或者
还或者
并且,如果有typedef:
C语言:
typedef struct Student{ int score; }Stu; //Stu是结构类型,是Student的别名,Stu==struct Student Stu stu1; //stu1是一个Stu结构类型的变量
或者
struct Student{ int score; }; struct Student stu1; //stu1是一个Student结构类型的变量,只能这样定义
还或者
typedef struct { int score; }Stu; //Stu是结构类型 Stu stu1; //这里只能这样定义一个新的变量
C++:
struct Student { int score; }; Student stu1;//比C语言少一个struct
并且,如果有typedef:
struct Student1 { int score; }stu1; //stu1是一个变量 typedef struct Student2 { int score; }stu2; //stu2是一个结构类型=struct Student1,等同于c语言
总结:
不用记住全部,只要记最习惯的写法,用c++:struct Student1 { int score; }stu1; //stu1是一个变量 Student1 stu2,stu3;
相关文章推荐
- 1.9 ID生成策略(xml方式的联合主键)
- codeforces 600D Area of Two Circles' Intersection
- 性能优化
- C提高_day03_两个辅助指针变量挖字符串(强化3)
- 温伯格技术思想三部曲:程序开发心理学——第6章、程序开发项目
- iOS开发>学无止境 - 自定义导航按钮UIBarButtonItem
- WCF 之角色验证
- SVN使用教程总结
- 通讯录小程序(C/C++)C语言练习小程序
- 函数返回语句与copy (move) constructor, copy (move) assignment operator的关系
- iOS开发>学无止境 - 只会左键断点?是时候试试这样那样断点了
- 中国通信学会科学技术奖 和 江苏通信行业科技进步奖 申报介绍
- CSS3 transform
- HDU 1060 Left-most Digit
- STM32学习第五天---看了CT117E比赛版的硬件结构
- ORACLE 使用DBLINK访问远程数据库
- Leetcode 第66题 Plus One
- POJ3667 Hotel
- 事件分发机制
- android添加购物车动画实现