0
What is the work of function overloading while programming?
what does function overloading do when we make games or apps ..
1 Odpowiedź
+ 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