g++
允许可变长度数组(VLA)作为扩展。 sizeof
操作者对VLAS结果非常有趣:gof对VLA的sizeof运算符进行了不同的评估吗?
int main()
{
char size = 20, a[10], b[size];
cout<<"sizeof(a) = "<<sizeof(a)<<endl; // sizeof(a) = 10, (can be used as template param)
cout<<"sizeof(b) = "<<sizeof(b)<<endl; // sizeof(b) = 20 !! (can't used be as template param)
}
在sizeof(b)
情况下,是克++不以下其中sizeof
仅在编译时评估的标准是什么?是sizeof
overloaded?
括号不是运算符名称的一部分。它是'sizeof',而不是'sizeof()'。 – unwind 2012-01-03 16:41:00