Why can I write this:
class VoiceManager
{
public:
static const int mMaxNumOfVoices = 16;
Voice mVoices[mMaxNumOfVoices];
private:
};
but I can not use this:
class VoiceManager
{
public:
const int mMaxNumOfVoices = 16;
Voice mVoices[mMaxNumOfVoices];
private:
};
It says: "the reference to the non-static element must be relative to a specific object"
But in both cases there mMaxNumOfVoicesis constand will be init before mVoicesinit (the compiler will execute the declaration order, no?).
But this is required static. Why?
source
share