When we use a Variadic function:
- Variadic function is used when you want to pass a slice in a function.
- Variadic function is used when we don't know the quantity of parameters.
- When you use variadic function in your program, it increase the readability of your program.
What does variadic mean?
From Wikipedia, the free encyclopedia. In computer science, an operator or function is variadic if it can take a varying number of arguments; that is, if its arity is not fixed.
How do Variadic functions work?
Variadic functions are defined by the standard, with very few explicit restrictions. Here is an example, lifted from cplusplus.com. In the most usual stack-based situation, the va_list is merely a pointer to the arguments sitting on the stack, and va_arg increments the pointer, casts it and dereferences it to a value.