October 2004
Intermediate to advanced
240 pages
6h 22m
English
Ellipses cause collapses: The ellipsis is a dangerous carryover from C. Avoid varargs, and use higher-level C++ constructs and libraries instead.
Functions taking a variable number of arguments are a nice commodity, but C-style varargs aren’t the way to get them. Varargs have many serious shortcomings:
• Lack of type safety: Essentially, the ellipsis tells the compiler: “Turn all checking off. I’ll take over from here and start reinterpret_casting.” (See Item 92.)
• Tight coupling and required manual cooperation between caller and callee: The language’s type checking has been disabled, so the call site must use alternate ways to communicate the types of the arguments being passed. Such protocols ...