warning: extended initializer lists only available with std c++ 11 [closed]

不羁岁月 提交于 2019-12-14 03:36:31

问题


Getting warning while using below code:

warning: extended initializer lists only available with std c++ 11

struct test{
 int a;
 int b;
};

//Previously const test atest[] = { {2,3} {4,5} };
const test atest[] = { {2,3} , {4,5} };

How can I remove this? I tried with solution, but it didn't work.


回答1:


const test atest[] = { {2,3}, {4,5} };

You forget the comma, and in C you need the struct keyword if test is not typedefed:

const struct test atest[] = { {2,3}, {4,5} };


来源:https://stackoverflow.com/questions/25281065/warning-extended-initializer-lists-only-available-with-std-c-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!