Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C+中的隐式数组大小+;11类似于C数组 在C++中你可以这样说: int xs[] = { 1, 2 };_C++_Arrays_C++11 - Fatal编程技术网

C+中的隐式数组大小+;11类似于C数组 在C++中你可以这样说: int xs[] = { 1, 2 };

C+中的隐式数组大小+;11类似于C数组 在C++中你可以这样说: int xs[] = { 1, 2 };,c++,arrays,c++11,C++,Arrays,C++11,在这里,可以在编译时将数组的大小推断为2,因此无需明确说明: int xs[2] = { 1, 2 }; 是否有与使用C++11数组的第一个构造等效的方法—一种不显式指定大小的定义方法?也许是这样的: array<int, _> xs = { 1, 2 }; // does not compile array xs={1,2};//不编译 而不必指定: array<int, 2> xs = { 1, 2 }; array xs={1,2};

在这里,可以在编译时将数组的大小推断为2,因此无需明确说明:

int xs[2] = { 1, 2 };
是否有与使用C++11数组的第一个构造等效的方法—一种不显式指定大小的定义方法?也许是这样的:

array<int, _> xs = { 1, 2 };  // does not compile
array xs={1,2};//不编译
而不必指定:

array<int, 2> xs = { 1, 2 };
array xs={1,2};