Method overriding, in object-oriented programming, is a language feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its superclasses or parent classes.
Method overriding is a feature of Object-oriented programming approach. It helps to achieve polymorphism. We can achieve method overriding using inheritance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | type Employee() = class abstract ShowName : unit -> unit default this.ShowName() = printfn"This is base class method" end type Manager() = class inherit Employee() override this.ShowName() = printf "This is derived class method" end let employee = new Employee() let manager = new Manager() employee.ShowName() manager.ShowName() |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.