9.C++中struct和C语言中的struct的区别

发布时间 2023-07-22 17:26:14作者: 小凉拖

C++中的stuct有继承多态,可以使用私有进行隐藏,可以封装函数,C语言没有以上功能。

1 struct Student{
2 };
3 Student st;//C++允许,C语言不允许,C语言应该是struct Student st;
4 //想要实现相似功能C语言应该按以下方式定义结构体
5 
6 typedef struct Student{
7 }Stu;
8 Stu st;//这在C语言中是允许的