我有一个名为 AppSettings 的类,其中有一个具有一系列音符频率的数组。我在下面的代码中遇到了几个错误,我不确定问题是什么。
错误消息是:
static data member of type 'const float [36] must be initialized out of line
A brace enclosed initializer is not allowed here before '{' token
Invalid in-class initialization of static data member of non-integral type
和代码:
class AppSettings{
public:
static const float noteFrequency[36] = {
// C C# D D# E F F# G G# A A# B
130.81, 138.59, 146.83, 155.56, 164.81, 174.61, 185.00, 196.00, 207.65, 220.00, 223.08, 246.94,
261.63, 277.18, 293.66, 311.13, 329.63, 349.23, 369.99, 392.00, 415.30, 440.00, 466.16, 493.88,
523.25, 554.37, 587.33, 622.25, 659.25, 698.46, 739.99, 783.99, 830.61, 880.00, 932.33, 987.77
};
};
顾名思义,这只是一个头文件,其中包含我在整个应用程序中需要的一些设置和值。