Oct 4, 2010, 09:24 PM
a simple question. how does a compiler figure out which function to execute when you multiple functions are given the same name(overloading)?
Oct 4, 2010, 09:36 PM
A function signature consists of the return type, the name, and the number and type of arguments. In most languages when a function is called the return type isn't easily discerned, so generally you can't have two methods with the same name and argument types and a different return type. This means the compiler depends on the name and the number and types of arguments. When a method is being invoked, the compiler can evaluate any expressions passed as arguments and use this information to decide what function will be called.