Calling Base Class Overriden Methods

Adam D. Ruppe destructionator at gmail.com
Mon Nov 18 11:34:55 PST 2013


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
}


More information about the Digitalmars-d-learn mailing list