gpt4 book ai didi

c++ - 将非静态常量数组声明为类成员

转载 作者:行者123 更新时间:2023-11-30 02:12:41 24 4
gpt4 key购买 nike

我们如何声明一个非静态常量数组作为类的属性?

以下代码产生编译错误

'Test::x' : member could not be initialized

class Test
{
public:
const int x[10];

public:
Test()
{
}
};

最佳答案

你应该阅读 this already posted question .由于不可能做你想做的事,解决方法是使用 std::vector。

关于c++ - 将非静态常量数组声明为类成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1518965/

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