64,939
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
#include<iostream>
#include<string>
using namespace std;
template<typename A, typename B>
struct score
{
A math;
B English;
friend ostream &operator<<(ostream &out, score &value)
{
out << value.math << "\t" << value.English << endl;
return out;
}
};
template <typename T>
struct student
{
string name;
T Score;
friend ostream &operator<<(ostream &out, student <T> &my)
{
out << "\t" << my.name << "\t" << my.Score << endl;
return out;
}
};
template <typename T>
class teacher
{
public:
T info;
teacher()
{
}
teacher(T s)
{
info.name = s.name;
info.Score.math = s.Score.math;
info.Score.English = s.Score.English;
}
void printf()
{
cout << info << endl;
}
};
int main()
{
student<score<int, int>> mystu = { "呵呵", { 100, 100 } };
teacher<student<score<int, int>>>mytea(mystu);
mytea.printf();
system("pause");
return 0;
}