c++ - How to put boost::multi_array in initialization list of constructor? -
i've got templated class dedicated holding boost:: multi_array
. trying initialize array in initialization class, getting error:
template <typename t> class hist2d { private: typedef boost::multi_array<t, 2> array_type; array_type matrixcount; public: hist2d(int width, int height): array_type matrixcount(boost::extents[width][height]){}; };
this gives following error:
ctest.cpp: in constructor ‘hist2d<t>::hist2d(int, int)’: ctest.cpp:34:45: error: expected ‘(’ before ‘matrixcount’ hist2d(int width, int height): array_type matrixcount(boost:extents[width][height]){}; ^ ctest.cpp:34:45: error: expected ‘{’ before ‘matrixcount’
what these errors mean?
it syntax error. not need declare type in initialization list.
try this:
hist2d(int width, int height): matrixcount(boost::extents[width][height]){}
c++ compilation errors can confusing. you'll used them after while :d
Comments
Post a Comment