我们如何将非静态 const 数组声明为类的属性?
以下代码会产生编译错误
'Test::x' : member could not be initialized
class Test
{
public:
const int x[10];
public:
Test()
{
}
};
最佳答案
您应该阅读this already posted question 。由于无法执行您想要的操作,因此解决方法是使用 std::vector。
关于c++ - 将非静态 const 数组声明为类成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1518965/