const
is not required in your case
for instance, both classes Matrix_A
and Matrix_B
below are the same for the compiler point of view. const
here is just to enforce the fact that ROWNUM
and COLNUM
are constant for humans point of view, but not required.
template <class T, int const ROWNUM, int const COLNUM>
class Matrix_A
{
};
template <class T, int ROWNUM, int COLNUM>
class Matrix_B
{
};
Moreover following class Matrix_C
also specify similar constant variables ROWNUM
and COLNUM
in another way:
template <class T>
class Matrix_C
{
static int const ROWNUM = 5;
static int const COLNUM = 20;
};
// the following three objects use constant variables ROWNUM and COLNUM
Matrix_A<bool,5,20> a;
Matrix_B<bool,5,20> b;
Matrix_C<bool> c;