Home » F# Inheritance

F# Inheritance

by Online Tutorials Library

F# Inheritance

Inheritance is a feature of object oriented programming approach. It allows inheriting property of base class in derived class. It increases reusability of code.

F# provides inherit keyword to use inheritance. If you don’t use inherit keyword by default it inherits object class. A class can have at most one direct base class. Derived class or subclass can access all the data members of base class except let binding which is private to base class.

You can access base class data members by using base keyword it acts like super keyword in java.


F# Inheritance Example

Following example illustrates how we can achieve inheritance in F#.

Output:

Name = Rajkumar  Salary = $10000  

You may also like