Safer casts
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Tue May 13 02:56:16 PDT 2008
Janice Caron wrote:
> 2008/5/13 Yigal Chripun <yigal100 at gmail.com>:
>> D needs to make it possible
>> to overload built-in properties.
>
> You can't overload something that isn't a class. Overloading requires
> inheritance.
Overloading works fine without a class:
---
import std.stdio;
void foo(int i) {
writefln("int %s", i);
}
void foo(char c) {
writefln("char %s", c);
}
void main() {
foo(42);
foo('A');
}
---
You're probably thinking of overriding, which requires a virtual method
in a base class.
More information about the Digitalmars-d
mailing list