O'Reilly logo

An Introduction to Design Patterns in C++ with Qt 4 by Paul Ezust, Alan Ezust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 24. Miscellaneous Topics

Variable length argument lists are referenced, but not completely explained earlier in the book, so they are discussed in this chapter. An example of resource sharing is also presented.

24.1

Functions with Variable-Length Argument Lists

542

24.2

Resource Sharing

543

Functions with Variable-Length Argument Lists

In C and in C++ it is possible to define functions that have parameter lists ending with an ellipsis (. . .). The ellipsis allows the number of parameters and their types to be specified by the caller. The usual example of such a function is from <stdio.h>.

int printf(char* formatstr, ...)

This flexible mechanism permits calls such as

printf("Eschew Obfuscation!\n"); printf("%d days hath %s\n", 30, "September");  ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required