我的问题是在代码中,但基本上我想知道如何/如果我可以做两条注释掉的线?我知道我可以在构造函数中完成,但我不想!如何初始化一个数组中的数组而不分别执行每个元素? (C++)
struct foo
{
int b[4];
} boo;
//boo.b[] = {7, 6, 5, 4}; // <- why doesn't this work? (syntax error : ']')
//boo.b = {7, 6, 5, 4}; // <- or else this? (syntax error : '{')
boo.b[0] = 7; // <- doing it this way is annoying
boo.b[1] = 6; // :
boo.b[2] = 5; // :
boo.b[3] = 4; // <- doing it this way is annoying
boo.b[4] = 3; // <- why does this work!
(使用:C++,Visual Studio 2005中)
这是另一种场合,可以宣传即将推出的C++ 11标准的统一初始化语法...... – sbi 2010-05-14 15:51:08