#include <stdio.h>
template<typename T1, typename T2>
class A
{
public:
typedef typename T1::type1 T11;
typedef typename T1::type2 T12;
typedef typename T2::type1 T21;
typedef typename T2::type2 T22;
A(T11 a, T12 b, T21 c, T22 d)
{
this->a = a;
this->b = b;
this->c = c;
this->d = d;
}
void show()
{
printf("%d\n%f\n%d\n%f\n",this->a,this->b,this->c,this->d);
}
private:
T11 a;
T12 b;
T21 c;
T22 d;
};
class E1
{
public:
typedef int type1;
typedef double type2;
};
class E2
{
public:
typedef int type1;
typedef double type2;
};
int main()
{
A<E1,E2> a(1,0.2,3,0.4);
a.show();
return 0;
}
c++ 类模板
最新推荐文章于 2023-05-14 16:09:53 发布