gpt4 book ai didi

c++ - 错误 : cannot specify explicit initializer for array

转载 作者:可可西里 更新时间:2023-11-01 17:15:56 26 4
gpt4 key购买 nike

我正在使用 Visual Studios 2013,但我一直收到此错误,但我不明白为什么。

class CLI{
string commands[2] = {"create", "login"};
public:
void addCommand(), start(), getCommand(string);
};

错误:

error C2536: 'CLI::CLI::commands': cannot specify explicit initializer for arrays

最佳答案

Visual Studio 2013 并不完全符合 C++11,因此,正如 Tobias Brandt 所说,您需要使用构造函数来初始化这些成员。

大括号初始化列表是 C++11 的一个特性。

关于c++ - 错误 : cannot specify explicit initializer for array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23900191/

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