Advantages of Function Overriding
- Code Reusability: Method overriding enables subordinates to extend methods developed in superordinates. This helps in preventing the same piece of code from being written in different classes which deal with similar functionalities.
- Polymorphism: Overriding helps in achieving polymorphism as it allows different methods of the parent class to be invoked depending on the instance of the object that triggered the method.
- Modularity: Function overriding also encourages the concept of modularity in code design because it allows subclasses to override specific methods.
- Specialization: Method overriding can be defined as a process that allows the subclasses in object oriented programming to alter the behavior of the methods inherited from the super classes.
Function overriding in programming
Function Overriding is a fundamental principle in object-oriented programming wherein the subclass implements a specific method that has been declared in the superclass. This concept would enable the method calls to be polymorphic where the same method call may behave differently depending on the object which initiated the method call. In this article, we will discuss the basics of Function Overriding along with its implementation in different languages.
Table of Content
- What is Function overriding?
- Function overriding in C++
- Function overriding in Java
- Function overriding in Python
- Function overriding in C#
- Function overriding in Javascript
- Advantages of Function Overriding
- Disadvantages of Function Overriding