基于C++可变模板参数的Log,任意个参数

class Log
{
public:
 Log();
 ~Log();
 template <typename T>
 static void i(const T& t) {
  cout << t << endl;
 }
 template <typename T, typename ... Args>
 static void i(const T& t, Args ... args) {
  cout << t << " ";
  i(args...);
 }
};

int main() {
 Log::i("hello", "world", 123, "yemao");
 return 0;
}

猜你喜欢

转载自blog.csdn.net/gychixxx/article/details/78916387
今日推荐