What is the work of function overloading while programming? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the work of function overloading while programming?

what does function overloading do when we make games or apps ..

26th Jan 2017, 3:48 PM
Prakash Agarwal
Prakash Agarwal - avatar
1 Answer
+ 3
Function overloading allows function name (eg constructor ) to be used with different argument types.Eg in a game, we could have a method Enemy() but would like 3 different types of enemies.These can be overlioaded as : Enemy(Monster_object m); Enemy(Ninja_object n); Therefore calls to this function will run a specific implementation(either Monster or Ninja) to the function appropriate to context of call. it also saves on memory space and the code can be reused
12th Feb 2017, 9:06 AM
Loise Muthoni