Rules in Function Overloading
- The overloaded function must differ either by the arity or data types.
- The same function name is used for various instances of function call.
It is a classification of static polymorphism in which a function call is resolved using the 'best match technique ', i.e., the function is resolved depending upon the argument list. Method overloading is usually associated with statically-typed programming languages which enforce type checking in function calls. When overloading a method, you are really just making a number of different methods that happen to have the same name. It is resolved at compile time which of these methods are used.
Method overloading should not be confused with forms of polymorphism where the correct method is chosen at runtime, e.g. through virtual functions, instead of statically.
Example: function overloading in c++
Read more about this topic: Function Overloading
Famous quotes containing the words rules and/or function:
“This was Pharaoh, direct descendent of our deity Amon, god of the sun, who rules the heavens as Pharaoh rules the earth. Again, he brought treasure, gold, and precious jewels taken from our enemies. For to Pharaoh riches were power and power was to be desired. And also again he brought many captives. For is it not by slaves that one becomes even richer and then has even more power?”
—William Faulkner (18971962)
“Uses are always much broader than functions, and usually far less contentious. The word function carries overtones of purpose and propriety, of concern with why something was developed rather than with how it has actually been found useful. The function of automobiles is to transport people and objects, but they are used for a variety of other purposesas homes, offices, bedrooms, henhouses, jetties, breakwaters, even offensive weapons.”
—Frank Smith (b. 1928)