<c++> variadic template Ex.1

本文参考了:

  1. 侯捷老师的c++讲义。
#include <iostream>
#include <bitset>
using namespace std;

void printX()
{
    
    
    /*nothing.*/
}

template <typename T, typename... Types>
void printX(const T& firstArg, const Types&... args)
{
    
    
    cout << firstArg << endl;
    printX(args...);
}

int main()
{
    
    
    printX(7.5, "hello", bitset<16>(377), 42);
	return 0;
}

执行结果:

7.5
hello
0000000101111001
42

猜你喜欢

转载自blog.csdn.net/gyhwind/article/details/115280013
今日推荐