i have class contains few multi-dimensional arrays. trying initialize these arrays in constructor, having trouble figuring our how it. array of fixed size. here's have far:
class foo { private: int* matrix; //a 10x10 array public: foo(); foo:foo() { matrix = new int[10][10]; //throws error }
the error is:
cannot convert `int (*)[10]' `int*' in assignment
how can accomplish this? preferably, array default 10x10 array of 0s.
#include <memory.h> class foo { public: foo() { memset(&matrix, 100*sizeof(int), 0); } private: int matrix[10][10]; };
that is, if you're not binding doing pointers (otherwise can pass in pointer memset, rather reference array).
Comments
Post a Comment