Does alias prevent hijacking?

Jacob Carlborg doob at me.com
Mon May 30 04:50:19 PDT 2011


On 2011-05-30 08:53, Kagamin wrote:
> class Base
> {
>    void foo(string s){}
> }
>
> class Derived: Base
> {
>    alias Base.foo foo;
>    void foo(long s){}
> }
>
> So far so good.
>
> Now add new method to the Base class.
>
> class Base
> {
>    void foo(string s){}
>    void foo(int s){}
> }
>
> Now behavior of the calling code silently changes.

Yes, but you've made an active choice by adding the alias.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list