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: Overloaded Expression
Famous quotes containing the words rules in, rules and/or function:
“There are two great rules in life, the one general and the other particular. The first is that every one can in the end get what he wants if he only tries. This is the general rule. The particular rule is that every individual is more or less of an exception to the general rule.”
—Samuel Butler (18351902)
“As no one can tell what was the Roman pronunciation, each nation makes the Latin conform, for the most part, to the rules of its own language; so that with us of the vowels only A has a peculiar sound.”
—Henry David Thoreau (18171862)
“Our father has an even more important function than modeling manhood for us. He is also the authority to let us relax the requirements of the masculine model: if our father accepts us, then that declares us masculine enough to join the company of men. We, in effect, have our diploma in masculinity and can go on to develop other skills.”
—Frank Pittman (20th century)