Construct immutable member in derived class
Timoses
timosesu at gmail.com
Wed Apr 4 21:49:08 UTC 2018
On Wednesday, 4 April 2018 at 16:16:24 UTC, Alex wrote:
> Here is something:
> https://dlang.org/spec/class.html#constructors
>
> By the rules 7 and 8 it is suggested, what Simen already said,
> the construction of the base class can be independent from the
> derived one. And as such, the immutability has to handled in
> the constructor, next to the variable...
"[...] the construction of the base class can be independent from
the derived one."
Hm, the points 7 and 8 don't clearly state what you wrote. But it
somehow does make sense.. Still I wonder why that is so.
Let's say you have an abstract class with immutable members. Why
shouldn't derived class constructors be allowed to initialize
these immutable members?
More information about the Digitalmars-d-learn
mailing list