Thread overview | |||||
---|---|---|---|---|---|
|
August 06, 2007 Override function in nested class | ||||
---|---|---|---|---|
| ||||
Hi, How to: Override a function in a static nested class? Example: class myclass1 { } |
August 06, 2007 Re: Override function in nested class | ||||
---|---|---|---|---|
| ||||
Posted in reply to Karl | Karl Wrote:
> Hi,
>
> How to: Override a function in a static nested class?
>
> Example:
>
> class myclass1
> {
>
> }
Sorry, i pressed the tab and enter to indent a line and posted, here's the example:
class myclass1
{
static class myclass2
{
void hello(){}
}
}
how do i override the hello function from a class inherited from myclass1?
thanks
|
August 06, 2007 Re: Override function in nested class | ||||
---|---|---|---|---|
| ||||
Posted in reply to Karl | Karl escribió:
> Karl Wrote:
>
>> Hi,
>>
>> How to: Override a function in a static nested class?
>>
>> Example:
>>
>> class myclass1
>> {
>>
>> }
>
> Sorry, i pressed the tab and enter to indent a line and posted, here's the example:
>
> class myclass1
> {
> static class myclass2
> {
> void hello(){}
> }
> }
>
> how do i override the hello function from a class inherited from myclass1?
>
> thanks
You can extend the static class:
class child2 : myclass1.myclass2 {
override void hello() {
writefln("Saluton!");
}
}
or you can extend both:
class child1 : myclass1 {
static class child2 : myclass1.myclass2 {
override void hello() {
writefln("Saluton!");
}
}
}
But you cannot just override the "hello" of myclass2 just by extending myclass1. Just as you cannot override static methods.
|
Copyright © 1999-2021 by the D Language Foundation