Function overloading question

Márcio Faustino m.faustino at no.spam.gmail.com
Sun Aug 26 00:23:24 PDT 2007


Hi,

Shouldn't the compiler (DMD v2.003) issue at least a warning when I do this?

//---------------------------------------------------------
import std.stdio;

void f(bool b, string which) {
	writefln("bool == ", which);
}

void f(char c, string which) {
	writefln("char == ", which);
}

void main() {
	// Here:
	void* fp = &f;
	
	// Which one will be called?
	(cast(void function(bool, string)) fp)(0, "bool");
	(cast(void function(char, string)) fp)(0, "char");
}
//---------------------------------------------------------

Thanks,


More information about the Digitalmars-d-learn mailing list