//第二十三模板 13模板成员
//模板可作为类,结构甚至模板类的成员
/*#include <iostream>
using namespace std;
template<class T1>
class One
{
public:
//不知道这里的i是什么意思
//One(T1 t, int i):first(t),second(t){}
One(T1 t, int i):first(t),second(i){}
template<class T2>
T2 get(T2 t2, T1 t1){
cout<<"second.get()返回"<<second.get()<<endl;
cout<<"first.get()返回"<<first.get()<<endl;
cout<<"get()函数接受的第一个参数为:"<<t2<<endl;
cout<<"get()函数接受的第二个参数为:"<<t1<<endl;
cout<<"以上四个数相加等:";
return (second.get()+first.get()+t2+t1);
}
void show()const{
cout<<"first.show()调用后输出:";
first.show();
cout<<"second.show()用后输出:";
second.show();
}
private:
template<class T3>
class two{
public:
two(T3 t3=0):x(t3){}
void show()const{cout<<x<<endl;}
T3 get()const{ return x;}
private:
T3 x;
};
two<T1>first; //用模板类声明了两个对first和second
two<int>second;
//由于这两个对像和模板类two以及模板类型T3都是在One类的私有区域被声明,因此只有One类的公有函数可以访问,外部不能访问
};
int main()
{
One<double> one(3.5,4);
one.show();
cout<<endl;
cout<<"执行get函数"<<endl;
cout<<one.get(10,2.3)<<endl;
return 0;
}*/