Although variable arguments
are the only way to have achieve certain goals in C
, and are used in the important I/O
, there are some distinct disadvantages:
must be implemented as macro
s which are evil
in their own right.
- There is no way to tell what type
of argument is being passed in. It could be a character string
, it could be an integer
, it could be your Aunt Matilda
. You have to assume that code that calls your routine is passing in the right type of information and hope that Aunt Matilda doesn't get hurt in the process. This defeats the entire purpose of writing in C++
Finally, there are always other, better ways in C++
to achieve whatever goal led you to want variable arguments in the first place. Use them instead.