c++ - structure overloading with dimension -



c++ - structure overloading with dimension -

struct range { size_t ndim; size_t stworksize[3]; size_t stoffest[3]; inline range ( size_t work_size ) { ndim = 1; stworksize [0] = work_size; stworksize [1] = stworksize [2] = 0; stoffest [0] = stoffest [1] = stoffest [2] = 0; } inline range ( size_t work_size[2] ) { ndim = 2; stworksize [0] = work_size[0]; stworksize [1] = work_size[1]; stworksize [2] = 0; stoffest [0] = stoffest [1] = stoffest [2] = 0; } inline range ( size_t work_size[3] ) { ndim = 3; stworksize [0] = work_size[0]; stworksize [1] = work_size[1]; stworksize [2] = work_size[2]; stoffest [0] = stoffest [1] = stoffest [2] = 0; } } ;

i hava construction defines above suggest me how overload dimension of constructor compiler gives me error range::range(size_t *) cannot overloader there method this

one of approaches following

inline range ( const size_t ( &work_size )[2] ) { ndim = 2; stworksize [0] = work_size[0]; stworksize [1] = work_size[1]; stworksize [2] = 0; stoffest [0] = stoffest [1] = stoffest [2] = 0; } inline range ( const size_t ( &work_size )[3] ) { ndim = 3; stworksize [0] = work_size[0]; stworksize [1] = work_size[1]; stworksize [2] = work_size[2]; stoffest [0] = stoffest [1] = stoffest [2] = 0; }

or define 1 constructor

inline range ( const size_t *work_size, size_t n );

c++

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -