ss(int m) : m(m)
{
}
This says that when the class ss
is initialized, its member m
is initialized using the parameter m
. The member m
indeed cannot be modified, but it can be initialized, just like any other const
object. Note that if we did instead
ss(int m)
{
this->m = m;
}
then we would have a problem, as ss::m
needs to be initialized. And if ss::m
were a class with a default constructor, then in
ss(FooClass m)
{
this->m = m;
}
it's OK to not initialize ss::m
explicitly (as it will just be default-constructed), but the line in the body of the constructor would be rejected as it would modify ss::m
after it has already been initialized.
Edit: Whoops, I didn't understand your original question.
A brace-or-equal-initializer such as
const int m = 1024;
is only used if the member is not mentioned in the ctor-initializer. In other words, since the default constructor doesn't explicitly initialize m
, the value 1024 is used. But ss::ss(int)
does explicitly initialize m
, so the brace-or-equal-initializer is ignored.