现在的位置: 首页 > 综合 > 正文

struct中初始化中的一个大错误

2017年10月12日 ⁄ 综合 ⁄ 共 766字 ⁄ 字号 评论关闭

If I have defined the struct as follows :

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

typedef struct  MyParam : public CommonParam
{
 float Image[1024];
int ImageType;

     MyParam()

          {

                Image[1024]={0.0,0.0};

                ImageType=10;

          }
};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

When I build it ,there are some errors ;

The reason is that :I confuse the initialization between  declaring  initialization and the struct initiazation ;Here ,we can't  initialize the array Image[1024] by this way ;we are supposed to give evey value for the
each element of the array ! That's just my error ;



抱歉!评论已关闭.