class C { const int ar[3]; public: C(int k) : ar({k,2*k,3*k}) {} C(const C& c) : ar(c.ar) {} };
does not compile! none of those constructors did manage to initialize C::ar, and leaving C::ar uninitialized is an error too. did I overlook something? is there any C++ implementation of the good old const-sized C-arrays? I guess something like this could be the solution: template<typename T_, unsigned char size=256> struct array { T_ carray[size]; //public for compatibility with C-functions template<typename T__> array(const array<T__, size>& a); array(T_, ...);//initialize by iterating over all arguments T_& operator[](const unsigned char i) {return carray[i];} operator array<T_, size-1> (); //reinterpret_cast to smaller array... template<unsigned char s_> array<T_, size-s_> operator+ (s_); //the same but using the tail... }; template<typename T_, unsigned short int size> struct array : array< array<T_>, 1+ size/256> {/*add implementation here*/};// :-) and of course above "int ar[3]" would then need to be replaced by "array<int,3> ar" and initialization would work without any {} around the list of terms. but don't try this at home :-)... does anyone know of similar implementations? how would g++ handle such an array-class during optimization, would it be the same as T_[size]? -- Better send the eMails to netscape.net, as to evade useless burthening of my provider's /dev/null... P _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus