Function Hijacking article

Aarti_pl aarti at interia.pl
Thu Oct 18 04:45:37 PDT 2007


Walter Bright pisze:
> http://www.digitalmars.com/d/hijack.html
> 
> (this is what my talk at NWCPP will be on tonight)
> 
> Digg: http://digg.com/programming/Function_Hijacking_Mitigation
> Reddit: http://programming.reddit.com/new

Very nice article!

Just please add inheritance (': A') in "Derived Class Member Function 
Hijacking #2", which is missing currently.

I finally got completely convinced for D inheritance way :-)

I noticed also in my implementation of ProgramOptions that such a 
behavior allows to hide base class implementation, making it possible to 
make better structured programs, compile time checked for functions usage:

// General base class
class A {
	// General implementation good for most of subclasses
	void opCall(int a, int b, int c) {}
}


// Specific implementation
class B : A {
	// Specific implementation for this class
	// Calling general implementation should not be allowed
	void opCall(char[] text) {}
}

Now you have compile time checking for B.opCall() and hidden base class 
methods opCall().

Really sweet!

BR
Marcin Kuszczak
(aarti_pl - www.zapytajmnie.com)



More information about the Digitalmars-d-announce mailing list