SO是一场狗屎秀。感谢您的搭车。
事情是这样的:
int const (&bar())[3];
要返回对数组的引用,请使用以下语法:
int const (& bar())[3];
尝试以下方法
int const (& bar() )[3]
{
static int const values[] = { 0, 1, 2 };
return values;
}
或者
typedef const int Three_Const_Ints[3];
Three_Const_Ints & f()
{
static Three_Const_Ints values = { 0, 1, 2 };
return values;
}