gpt4 book ai didi

c++ - 尝试使用 const int std::array 时出错

转载 作者:太空宇宙 更新时间:2023-11-04 14:52:32 25 4
gpt4 key购买 nike

<分区>

为什么当我尝试使用 const int std::array 时出现以下错误?我必须将错误消息中的“<”替换为“<\”才能正确显示:

#include <array>
#include <iostream>

using namespace std;

int main() {
array<const int, 4> vals;

return 0;
}

test.cpp: In function ‘int main()’:

test.cpp:7:22: error: use of deleted function ‘std::array::array()’

array<\const int, 4> vals; ^~~~

In file included from test.cpp:1:0: /usr/include/c++/7.3.0/array:94:12: note: ‘std::array<\const int, 4>::array()’ is implicitly deleted because the default definition would be ill-formed: struct array ^~~~~

/usr/include/c++/7.3.0/array:94:12: error: uninitialized const member in ‘struct std::array<\const int, 4>’

/usr/include/c++/7.3.0/array:110:56: note: ‘const int std::array<\const int, 4>::_M_elems [4]’ should be initialized typename _AT_Type::_Type _M_elems; ^~~~~~~~

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com