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 Matrix_A
{
};
template
class Matrix_B
{
};
Moreover following class Matrix_C
also specify similar constant variables ROWNUM
and COLNUM
in another way:
template
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 a;
Matrix_B b;
Matrix_C c;