4 ms·
> What I have specifically is a class that provides a base set of operations and a subclass that lets you do some modifications Your object isn't actually immu
by munchbunny 7y ago
> What I have specifically is a class that provides a base set of operations and a subclass that lets you do some modifications
Your object isn't actually immutable, it just doesn't let you directly mutate it. That's a really important distinction.
That's a common pattern. In C++, rather than using a subclass for the mutator, use a different (friend) class. The semantics for implicit conversion between two different classes will allow you to accomplish what you are asking for with enforcing no changes from one interface but not the other.
- saagarjha 7y ago> In C++, rather than using a subclass for the mutator, use a different (friend) class. Unfortunately I don't control this class :(