How define a array that has constant default value in class?

To add comments, please log in or register
beikez
16
beikez  

How define a array that has constant default value in class?

double testArr[] = {55,128,244,311}; //Ok

class MyClass1
{
protected:
        double m_constant[] = {55,128,244,311}; //Error!!

public:
        MyClass1(void);
        ~MyClass1(void);
};

Thanks!

whroeder1
17943
whroeder1  
If the array is constant, make it static.
class MyClass1{
protected:
        static const double m_constant[];
:
};
static const double MyClass1::m_constant[] = {55,128,244,311};
To add comments, please log in or register