Calling baseclass methods in derived class fucntions

class strategy {
     property_ = array();

     function getProperty() { return property_; }

     function getDelay() { return 0; }
}

class derivedStrategy extends strategy {
     function getDelay() {
          local prop = getProperty();
           // do some additional work
          return 1;   
     }
}

Simplifying the problem i am facing in the two classes above.

  1. I could not find in the documentation if i could directly access the property_ member variable in the derivedStrategy class.
  2. Added an accessor to get around the problem of not being able to access the property_ member in the overridden getDelay() method of the derivedStrategy class. But at the call site in deriveStrategy during runtime i see the error ‘the index of getProperty does not exist’ error.

Is there a reason why i am not able to access the getProperty() function of the base class, in the overridden function getDelay() in the derived class? I have tried many variants including calling it with a base.getProperty(), in which case it finds it, but then i see the error message ‘the index of property_ does not exist’ at runtime.

The example code i posted above, is working if i paste it and run it on the device. But used in my application it is NOT working.

I am still looking at my code, to see if i am done something to get these errors. Will try stripping down my actual code to see where i made the mistake.

Eventhough i did not declare the callback function as a static, it was being treated as a static method, and hence accessing any non static functions or properties was giving errors. I was able to separate out the code to eliminate the issue.

What you can try is to declare property_ as null and then use a constructor to set it (to an instance of array()):

class strategy {
    property_ = null;

    constructor () { property_ = array(); }

    function getProperty() { return property_; }

    function getDelay() { return 0; }
}