0

Say in a moment my parameters are (int). Then its (char). Then (char, int) and there goes on. Don't ask why, we are just doing Science here.

Edit: Some people suggested I use a loop to pass many parameters, others to use pointers. I'm not sure if I understood the question, I feel sometimes I focus too much on messing deep into things but it's just for learning purposes.

MLavoie
  • 9,671
  • 41
  • 36
  • 56

2 Answers2

0

You cannot change the parameters of a function at runtime. A function is specifically coded for some parameters, changing it would require modifying it to use the new parameters, changing the entire function. Such edits are not possible, and should not be (Mentally visualizing such code would be extremely difficult. How would you keep track of such changes? How would debugging work?)

If you need your code to use different functions depending on some conditions, use if else/switch statements.

0

You can try variadic templates to simulate such behavior. See this answer for details

Community
  • 1
  • 1
VeminZ
  • 78
  • 6