#有点小激动,人生中第一篇博客#
C++没学好,导致学数据结构也很痛苦,只能一点一点再重新把知识捡回来;
最近用结构体十分频繁,所以这篇博客就先来整整结构体好了。
结构体类型的定义
①
struct student
{
int num;
char name[20];
char sex;
int age;
float score;
};
Tips:
- student 是结构体名,是定义的结构体类型,可以用它来定义变量,如:
或者struct student s1;
s1 即为 struct student 类型的变量,即具有 struct student 类型的结构。student s1;
在定义结构体类型的同时定义变量↓:
这样定义的s1则为全局变量(一个好的程序应该有这样的特点:尽量少用全局变量,函数尽量独立)struct student { int num; char name[20]; char sex; int age; float score; }s1;
这struct { int num; char name[20]; char sex; int age; float score; }s1;

这篇博客探讨了C++中的结构体(struct)和typedef struct的使用。讲解了如何定义结构体类型及其变量,强调了typedef在提高代码可读性方面的作用。通过示例解释了SqList和LinkList等别名的定义,并指出LNode和struct node*之间的等价关系,同时指出在某些情况下直接使用struct node*会导致错误。
&spm=1001.2101.3001.5002&articleId=79999783&d=1&t=3&u=89a49cbbfcca44ff89de1cff13fb43c9)
1411

被折叠的 条评论
为什么被折叠?



