LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   const/static members in classes (https://www.linuxquestions.org/questions/programming-9/const-static-members-in-classes-428820/)

lucky6969b 03-26-2006 09:31 PM

const/static members in classes
 
I couldn't declare a class like this
class a
{
public:
const float[4] anArray = { 1.1f, 2.2f, 3.3f, 4.4f };
};

I don't see why there is a problem.
A class cannot contain constants?
Any comments are welcome
Thanks
Jack

graemef 03-26-2006 09:50 PM

try initialising the constant in the constructor.

or make them static const and initialise them as you would other static member variables.

ta0kira 03-27-2006 05:43 PM

'[4]' needs to be after 'anArray'.
ta0kira


All times are GMT -5. The time now is 12:14 AM.