   Problem initializing arrays within constructors?
  Hi guys :)I have something similar to the following:class MyClass{private:int myArray[9];}MyClass::MyClass(){myArray[] = {2,5,3,2,4,5,3,5,3};}and no matter how I swap syntax around I can only get it to compile if I get rid of the declaration in the class and only create and initialize it in the constructor. What am I doing wrong?   
  You cannot initialize member arrays directly in the current C++ standard. What you can do is initialize a local array and then copy the elements over.#include <algorithm>class MyClass{private:    int myArray[9];public:    MyClass();};MyClass::MyClass(){    int temp[] = {2,5,3,2,4,5,3,5,3};    std::copy(temp, temp + 9, myArray);};  another option is to make your array static and then you can declare your variables as you want.   ;  Thank you both for the insight :D   ;Quote:Original post by mmakrzemanother option is to make your array static and then you can declare your variables as you want.That, however, results in quite different behavior. Class instances will 'share' a static member with each other, rather than having their own. You'd have to be sure that that is what you want.   