3 ms·
How is there a smaller set because of OOP? Just filter the functions by parameter type to restrict which function may access your pointer.
by beeforpork 6y ago
How is there a smaller set because of OOP? Just filter the functions by parameter type to restrict which function may access your pointer.
- Jtsummers 6y agoOOP encourages modifying an object's state via its member functions (if you use data hiding/encapsulation as part of your OOP definition). This means that users of class instances shouldn't be able to put it into a bad state, unless the member functions are able to put it in a bad state. This lets you isolate where your contract/invariant violations are more easily. Once addressed in the member functions, either it fixes it in the callers, or their use is now invalid and becomes a compile or runtime error.