48.函数模板与引用包装器

 1 #include <iostream>
 2 using namespace std;
 3 
 4 template <class T>
 5 void show(T t)
 6 {
 7     cout << t << endl;
 8     t += 10;
 9 }
10 
11 void main()
12 {
13     double db(1.0);
14     double &ldb(db);
15     //引用包装器,声明为一个引用
16     show(ref(ldb));
17     cout << db << endl;
18     cin.get();
19 }

 

posted @ 2018-03-12 23:00  喵小喵~  阅读(98)  评论(0编辑  收藏  举报