- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Variadic function templates in C++
Variadic function templates in C++ is a function which can take a multiple number of arguments.
Syntax
template(typename arg, typename... args) return_type function_name(arg var1, args... var2)
Example Code
#include <iostream> using namespace std; void show() //base case. { cout << "I am now empty"; } template <typename T, typename... T2>// variadic function void show(T v1, T2... v2) { cout << v1 << endl; show(v2...) ; } int main() { show(7, 6, 0.04, "hi ","I am variadic function","I will show\n"); return 0; }
Output
7 6 0.04 hi I am variadic function I will show I am now empty
Advertisements
To Continue Learning Please Login
Login with Google