readonly?
Namespace
rswhite4 at googlemail.com
Tue Jul 10 12:27:54 PDT 2012
Maybe D need's a readonly keyword.
Sometimes i have a class which can take an object from
everywhere to store it. So it can not be const, because i didn't
just initialized it with a ctor.
But i don't want to change the object, i only want to read or
call const methods. What now?
I'd suggest a readonly keyword for that.
[code]
class Foo {
readonly:
Bar _b;
public:
void SetBar(readonly Bar b) {
_b = b;
}
}
[/code]
Or has D an alternative?
More information about the Digitalmars-d-learn
mailing list