cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
"infinite" amount of params like printf.
"infinite" amount of params like printf... how to?
Jul 30, 2012 at 1:13am UTC
beakie
(166)
How do I make a function with an unspecified amount of parameters... like printf does()?
Cheers
Jul 30, 2012 at 1:15am UTC
AbstractionAnon
(6954)
http://cplusplus.com/reference/clibrary/cstdarg/
Jul 30, 2012 at 9:12am UTC
Peter87
(11234)
In C++11 you can use variadic templates. The advantages with this approach is that it is more type safe and it's possible to verify that the number of arguments is correct.
http://en.wikipedia.org/wiki/Variadic_template
Look at the printf example.
Last edited on
Jul 30, 2012 at 9:13am UTC
Topic archived. No new replies allowed.