【发布时间】:2018-03-17 01:19:23
【问题描述】:
我正在尝试在我的班级中使用 C++ 数组:
#include <array>
#include <iostream>
using namespace std;
class Test {
private:
const size_t NCOL = 4;
array<int, NCOL> row;
public:
Test(){}
~Test(){}
};
int main() {
Test t;
return 0;
}
但我收到以下错误消息,但我不知道为什么:
test.cpp:9:14:错误:非静态数据成员“Test::NCOL”的使用无效 数组我该如何解决这个问题?
【问题讨论】:
-
你想要
const和static。这不是 C#。