私はこのようなことをしています
Class.hpp:
class Class {
private:
static const unsigned int arraySize;
int ar[arraySize+2];
};
Class.cpp:
#include <Class.hpp>
const unsigned int arraySize = 384;
コンパイラ (q++、g++ ベースの QNX OS 用の c++ コンパイラ) は、 (Class.cpp のコンパイル中ではなく)error: array bound is not an integer constant
ユニットのコンパイル中に提供します。Class.hpp
なぜそれが機能しないのですか?静的な const メンバーは、C++ 標準で保証されている配列バインドとして使用できることを知っています (この anwserを参照)。しかし、なぜコンパイラは の結果をstatic const + const
定数として認識しないのでしょうか?