digitalmars.D - Re: Hijacking
- Ender KaShae <astrothayne gmail.com> Aug 06 2007
kris Wrote:Walter: There's a related problem where a public method is added to a base-class A (as in your example) but where the signature is *exactly* that of one existing in derived class B. If A actually calls that new method internally, "bad things"tm will almost certainly happen, since B never intended to effectively override the newly-added method in A. This is a very hard problem to isolate yet can be easily remedied by the compiler. The request was first made two or three years back, and once or twice since then: you make the "override" keyword *required*. When "override" is required, the compiler can easily trap this related type of hijacking and avoid such nasty surprises.
if the function is overrided ONLY when the override keyword is there would prevent prevent any errors when such an action occurrs, but you also run into the bittersweet situation of hiding members of the base class.
Aug 06 2007