Function Hijacking article
    Walter Bright 
    newshound1 at digitalmars.com
       
    Thu Oct 18 16:40:39 PDT 2007
    
    
  
Stewart Gordon wrote:
> "Walter Bright" <newshound1 at digitalmars.com> wrote in message 
> news:ff8fi1$fs7$1 at digitalmars.com...
>> Stewart Gordon wrote:
> <snip>
>>> And I noticed that the requirement to specify the override attribute 
>>> is neither implemented nor documented under attribute.html - what gives?
>>
>> It is documented in the function.html and attribute.html.
> 
> I still can't find it anywhere.
In attribute.html, click on "override" under "Attribute" in the grammar 
section. In function.html, search for "override".
> 
>> It is implemented if you add the -w switch.
> 
> I see....
> 
> <snip>
>>> But if there's no chance of calling one intending the other, e.g.
>>>
>>> class Qwert {
>>>    void yuiop(int i)    { writefln("Qwert.yuiop: int %d", i); }
>>>    void yuiop(string s) { writefln("Qwert.yuiop: string %s", s); }
>>> }
>>>
>>> class Asdfg : Qwert {
>>>    override void yuiop(string s) { writefln("Asdfg.yuiop: string %s", 
>>> s); }
>>> }
>>>
>>> should it still count?
>>
>> Yes, because Qwert can have a function which calls yuiop(int) with an 
>> Asdfg instance.
> 
> I'm not with you.  How exactly does this render my example susceptible 
> to the hijacking problem?
If Qwert defines a function def:
	void def()
	{
		yuiop(1);
	}
    
    
More information about the Digitalmars-d-announce
mailing list