The C++ Compass
|
>FAQ<
|
Home Risorse Utilities Compilatori GUI Toolkits Libri Download FAQ Who am I |
Come si usano le funzioni con un numero variabile di argomenti ? Ecco un piccolo esempio : #include <iostream> #include <cstdarg> void numeri(const int n0, ... ) { std::va_list args; std::va_start(args, n0); int n; while((n = std::va_arg(args, int))>0) { std::cout << n << '\n'; } std::cout << std::endl; std::va_end(args); } int main() { numeri( 0, 1, 2, 3, 4, 5, 10, 20, 0 ); } |
webmaster@thecppcompass.org |