Do any OO languages support a mechanism to guarantee an overriden method will call the base?

Posted by Aaron Anodide on Programmers See other posts from Programmers or by Aaron Anodide
Published on 2012-09-26T03:52:51Z Indexed on 2012/09/26 9:51 UTC
Read the original article Hit count: 242

Filed under:

I think this might be a useful language feature and was wondering if any languages already support it.

The idea is if you have:

class C
  virtual F
     statement1
     statement2

and

class D inherits C
  override F
     statement1
     statement2
     C.F()

There would be a keyword applied to C.F() such that removing the last line of code above would cause a compiler error because it's saying "This method can be overridden but the implementation here needs to run no matter what".

© Programmers or respective owner

Related posts about programming-languages