C++的结构体struct和C语言的结构体的区别

在定义好结构体stu后,使用这个结构体类型的时候,C语言需要写关键字struct,而C++里面可以省略不写:

#include <iostream>
#include <string>
using namespace std;

int main()
{
	struct stu
	{
		int grade;
		float score;
	};

	struct stu arrl[10]; //C语言中需要写struct
	stu arr2[10]; //C++里面不需要写

	return 0;
}
发布了20 篇原创文章 · 获赞 25 · 访问量 913

猜你喜欢

转载自blog.csdn.net/weixin_43699840/article/details/104480517