Thanks for mentioning this! Please do me a favor if you will!
Originally Posted by laserlight
And tell me in plain English what does this principle say exactly! I could not understand it from it's definition on Wiki!
The function in base class is virtual and then redefined with additional argument in derived class. Does that conflict
with the above mentioned principle?
And anybody else besides laserlight, if you can explain the principle to me! Please do! Thanks!
In simple terms:
All objects derived from base should have ALL the properties of base - and possibly extensions, but should not remove anything.
The purpose of this is so that you can have functions that don't know about further enhancements to the base or derived class, as long as the function doesn't actually NEED to use any of the enhanced functionality of the class itself. But if you hide a base-class function with a differnet signature function, you obviously haven't got the same funcutions as base any more.
Thanks a lot matsp!
That explanation really got into my mind! I mean thanks for nice explanation :)
And that Wiki definition is too scary ^_^
After some thought.
Could it be possible that the redefinition was intentional.
I mean the original writer of both the classes really wanted to hide the function in base class?
What purpose it would serve? Is it normal practice? Is it clean software design?
That's why I tried to put it in simpler terms. The wiki entry is good if you are really into that sort of stuff, but it's not simple to understand.
Originally Posted by manav
Hey, could that redefinition be intentional? See my post edited!
It COULD be intentional, but it's certainly NOT normal practice or clean design to do that - it's very UGLY design. If you want to "hide" the functionality correctly, you replace the function in the derived class with one that does nothing, or that does something else, or whatever is appropriate.
If possible, perhaps you can ask the original author of the code?