来自cppreference :
In the following cases the expression specifying the first dimension is erroneous:
- the value is smaller than the number of array elements provided in the brace-enclosed initializer (including the terminating
\0
on a string literal).
有人可以提供一个示例,说明字符串文字太长以至于它限制了数组新表达式的第一个维度吗?
我似乎想不出一个:(
我看到的唯一有点相似的东西是类似 auto p1 = new char[1][5]{"xyz"};
的东西。但这与第一个维度无关。
最佳答案
类似这样的事情:
new const char[2]{"this is way more than one character"};
请注意,gcc 甚至不编译 new const char[2]{"x"}
,但这是一个正交问题。
关于c++ - 字符串文字边界数组新表达式第一维参数的示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49679114/