Calling Base Class Overriden Methods

Jeroen Bollen jbinero at gmail.com
Mon Nov 18 11:36:06 PST 2013


On Monday, 18 November 2013 at 19:34:56 UTC, Adam D. Ruppe wrote:
> On Monday, 18 November 2013 at 19:32:39 UTC, Jeroen Bollen 
> wrote:
>> How do I call a parent class's overidden method?
>
> super.method
>
> so
>
> abstract class SuperClass {
>     public pure void methodA() {
>
>     }
> }
>
> class SubClass : SuperClass {
>     public override pure void methodA() {
>         // calls the parents
>         super.methodA();
>     }
> }
>
>
> To do it from outside the class, you write the class name:
>
>
> void main() {
>         auto obj = new SubClass();
>         obj.SuperClass.methodA(); // calls the specific super 
> method
> }

Thanks! :D

Why aren't these things in the documentation? :/


More information about the Digitalmars-d-learn mailing list