Template class array definition is not type name, static or enumerator C++ -
i writing template class function dynamic array , stumbling @ 1 issue , cannot work out what's wrong. have goggled , come nil have fixed 1 issue similar adding class name , variable size still these two. here code
template<class val> class dynamarray { private: const int ksegmentsize = 15; int countpos; val initial[dynamarray::ksegmentsize]; public: dynamarray::dynamarray(); dynamarray::~dynamarray(); void dynamarray::putval(val value); val dynamarray::getval(); };
the array initial causing error prepare first issue added dynamarray::
, error disappeared 1 remains , have no thought remaining here re-create of total error.
error c2327: 'dynamarray<std::string>::ksegmentsize' : not type name, static, or enumerator
then get
error c2065: 'ksegmentsize' : undeclared identifier
if has ideas appreciated.
this
const int ksegmentsize = 15; val initial[dynamarray::ksegmentsize];
should be
static const int ksegmentsize = 15; val initial[ksegmentsize];
as static integrals allowed specify array size in-class declarations.
c++ arrays class templates
No comments:
Post a Comment