Re: Private functions
Nilone <reaanb@gmail.com> wrote:
On Aug 10, 2:38?pm, "Daniel T." <danie...@earthlink.net> wrote:
Chris P. Stubbs wrote:
i) Is overriding public virtual functions with private functions
good practice?
Yes, it helps ensure that clients are using the interface class
rather than the implementation class.
I disagree. It breaks the guarantees made by the interface. Why
specify in the interface that all derived classes do something, when
that isn't true?
It breaks no such guarantees. You can still call the functions through
the interface.
ii) Are there any disadvantages?
The only disadvantege, if you want to call it that, is that the
clients need to up-cast the object to use the member-functions in
question.
It's like saying all birds can fly, and then saying that a penguin
can't fly. Then, to get a penguin to fly, you ignore the fact that
it is a penguin. It seems to me the OP needs to study Aristotle's
syllogism, and then make up his/her mind.
Not at all. As long as LSP isn't violated, it helps ensure that objects
are used through their interfaces. That's a good thing, not a bad thing.