As i understood, template value need to be known in compilation time. so i write a little example just to see that i get it, but apperantly i didn't. so i get this:
`defValue' cannot appear in a constant-
expression
can anyone please what is the problem and how it can be fixed?
#include <iostream>
template <class T,T defaultVal, int dim=255>
class Vec
{
T _vec[dim];
int _dim;
public:
Vec () : _dim(dim)
{
for (int i=0;i<_dim;++i)
{
_vec[i] = defaultVal;
}
}
~Vec () {};
// other operators and stuff
};
int main ()
{
int defValue = 0;
Vec < int,defValue > vecWithDefVal;// here is the problem but i don't know why
}