C++ - 数组类型"无符号__int64 [金额*]"不可分配

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

本文关键字:金额 不可分 可分配 int64 类型 无符号 C++ 数组      更新时间:2023-10-16

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

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

a收到错误

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);