c++ - Allocating an array in a templated class -


the template i'm using is

template<typename t, size_type max_dim = 500> 

i trying figure out how allocate correctly. variable t ** array_ declared in constructor. have right now, i've tried few different kinds of syntax no avail.

array_=new value_type*[dim1_];     ( long = 0u; < dim1_; i++)         array_[i] = new value_type[dim2_]; 

i don't understand why using value_type when template argument t use it:

template<typename t, size_t max_size = 500> class myarray {     t** array_; public:     myarray(size_t dim1_, size_t dim2)     {         array_ = new t*[dim1_];         (size_t = 0; < dim2; ++i)           array_[i] = new t[dim2];     } }; 

mind since not using std::vector nor std::array need release memory manually through delete [] in destructor.


Comments

Popular posts from this blog

round image using picasso in android -

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

python - How to remove the Xframe Options header in django? -