gpt4 book ai didi

C++ - 数组类型 'unsigned __int64 [amount*]' 不可分配

转载 作者:行者123 更新时间:2023-11-28 05:54:32 26 4
gpt4 key购买 nike

我正在 Visual 2015 和这部分代码中编写算法的实现

int amount;
//some code that change value of variable amount
uint64_t table[amount*9];

有一个错误

array type 'unsigned __int64 [amount*]' is not assignable

我读到我应该初始化一个数组所以我做了

uint64_t table[amount*9] = {0};

但这并没有帮助。有什么建议吗??

最佳答案

C++ 不支持可变大小的数组。使用 std::vector 代替:

    int amount;
//some code that change value of variable amount
std::vector<uint64_t> table(amount*9);

关于C++ - 数组类型 'unsigned __int64 [amount*]' 不可分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34484034/

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