Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

FuuFuu

macrumors regular
Original poster
Jul 8, 2008
226
0
Roselle
a simple question. how does a compiler figure out which function to execute when you multiple functions are given the same name(overloading)?


thanks
 
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.

-Lee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.