June 08, 2004 overload | ||||
---|---|---|---|---|
| ||||
I don't think this is new, but anyway... ############ class Bug { void foo() { } static void foo(int i) { } static void bar() { foo(1); } } int main(char[][] args) { } #################### dmd O.d -I~/dmd/src/phobos O.d(14): 'this' is only allowed in non-static member functions #################### |
July 01, 2004 Re: overload | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ant | On Tue, 08 Jun 2004 19:21:56 -0400, Ant wrote:
> I don't think this is new, but anyway...
>
> ############
> class Bug
> {
>
> void foo()
> {
> }
>
> static void foo(int i)
> {
> }
>
> static void bar()
> {
> foo(1);
> }
> }
>
> int main(char[][] args)
> {
> }
>
> ####################
> dmd O.d -I~/dmd/src/phobos
> O.d(14): 'this' is only allowed in non-static member functions
> ####################
still a problem in 0.94
however if we change the order we define the functions
to have the static foo first compiles and runs
#####################
class Bug
{
static void foo(int i)
{
printf("static void foo\n");
}
void foo()
{
printf("void foo\n");
}
static void bar()
{
printf("static void bar\n");
foo(1);
}
}
int main(char[][] args)
{
Bug b = new Bug;
b.foo();
b.bar();
return 0;
}
#####################
|
Copyright © 1999-2021 by the D Language Foundation