C++与C语言在结构体上的区别

用Nios 实现逻辑上很清楚,只是C++用switch语句后,写的很麻烦,主要是Switch语句很长吧。

另外要记录下:struct在C++中,在a文件中定义在b文件中定义变量是可以的,但在C语言中,定义变量时要加上struct 如下:

复制代码
A.c

struct dim{

  int x;

  int y ;

}

B.c

#include"A.c"

struct  dim_exm dim;



c.cpp

#include"A.c"

dim_exm dim;
复制代码

另外就是struct变量的赋值与初始化有区别。

复制代码
初始化过程中
dim_exm dim = {1920,1080};
但是在赋值过程
dim = {1920,1080};是错误的,
目前只知道
dim.x = 1920
dim.y = 1080
是可以的
复制代码
原文地址:https://www.cnblogs.com/zhongguo135/p/9458798.html