我在结构内的结构上遇到问题:
typedef struct BrickStruct
{
int type;
SDL_Rect Brick_Coordinates;
SDL_Surface *Brick_Surface = NULL;
}BrickStruct;
我的编译器说的是关于SDL_Surface
结构的一行:
error: expected ':', ',', ';', '}' or '__attribute__' before '=' token
但是我不太了解,因为我在我的老师面前上了关于结构指针的课程,说: Coordinate *point = NULL;
坐标是具有两个int
内部结构:int x,y;
有人可以向我解释那奇怪的事吗?
谢谢
C语言不允许这样内联初始化实例字段。标准做法是编写一种工厂风格的方法来为您进行初始化
BrickStruct create_brick_struct()
{
BrickStruct s;
s.Brick_Surface = NULL;
s.type = <default type value>;
s.Brick_Coordinates = <default coordinatos value>;
return s;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句