3 ms·
I mentioned one such example about 6 hours before your post. As the other reply stated, when you mostly want to keep the base class but over-ride a small speci
by mjevans 10y ago
I mentioned one such example about 6 hours before your post.
As the other reply stated, when you mostly want to keep the base class but over-ride a small specific subset of what it does.
E.G.
The base class uses class member functions to do save/load records from a store.
You want to implement a variant of that class which instead works well with a database engine you like.
You can then derive a class and define JUST the storage and recall functions, and inherit everything else.
- cousin_it 10y agoInterfaces are a better tool for that case IMO. One small utility interface (save/load) and two implementations would be easier to test in isolation and wouldn't suffer from the fragile base class problem.