|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
D - overloaded module and class functions
Hi,
The compiler complains that "function func () does not match argument
types (char)" in the call func(this.value). Shouldn't it call the func(char)
defined in the module instead of trying to apply the func method member? I'm
using dmd 0.48.
int main() {
printf("%c\r\n", (new A('a')).func());
return 0;
}
class A {
private char value;
this(char c) {
this.value = c;
}
public char func() {
return func(this.value);
}
}
char func(char c) {
return c;
}
Best regards,
Daniel Yokomiso.
"The difference between me and the other surrealists is that I'm a
surrealist."
- Dali
Nov 15 2002
Usual I will divide the codes to minimum units. put its in each lines. that more ease to debug. li :) "Daniel Yokomiso" <daniel_yokomiso yahoo.com.br> 写入消息新闻 :ar3nho$1t3u$1 digitaldaemon.com... Nov 15 2002
No, each scope has its own, seperate function overloading. The reason is to
try to avoid the confusion of multiple scopes interfering with each other.
You can write a 'forwarding function', however, to forward a function call
out of scope:
char func(char c)
{
return some_other_scope.func(c);
}
"Daniel Yokomiso" <daniel_yokomiso yahoo.com.br> wrote in message
news:ar3nho$1t3u$1 digitaldaemon.com...
Nov 15 2002
|