#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
class Teacher;
class Student
{private:
int num;
string name;
string sex;
string position;
public:
Student(){};
Student(int n,string a,string s,string p):num(n),name(a),sex(s),position(p){}
friend Teacher;
};
class Teacher
{public:
void display(Student &);
Teacher(){}
Teacher(int n,string a,string s,string p):num(n),name(a),sex(s),position(p){}
private:
int num;
string name;
string sex;
string position;
};
void Teacher::display(Student &s)
{num=s.num;
name=s.name;
sex=s.sex;
position="Teacher";
cout<<"留校后,该学生的信息被转换为:"<<endl;
cout<<setw(4)<<"num"<<setw(10)<<"name"<<setw(6)<<"sex"<<setw(10)<<"position"<<endl;
cout<<setw(4)<<num<<setw(10)<<name<<setw(6)<<sex<<setw(10)<<position<<endl;
}
int main()
{
Student stu[2]={Student(1001,"Zhang","male","Student"),Student(1023,"Wang","male","Student")};
Teacher t1;
for(int i=0;i<2;i++)
t1.display(stu[i] );
return 0;
}
#include<iomanip>
#include<string>
using namespace std;
class Teacher;
class Student
{private:
int num;
string name;
string sex;
string position;
public:
Student(){};
Student(int n,string a,string s,string p):num(n),name(a),sex(s),position(p){}
friend Teacher;
};
class Teacher
{public:
void display(Student &);
Teacher(){}
Teacher(int n,string a,string s,string p):num(n),name(a),sex(s),position(p){}
private:
int num;
string name;
string sex;
string position;
};
void Teacher::display(Student &s)
{num=s.num;
name=s.name;
sex=s.sex;
position="Teacher";
cout<<"留校后,该学生的信息被转换为:"<<endl;
cout<<setw(4)<<"num"<<setw(10)<<"name"<<setw(6)<<"sex"<<setw(10)<<"position"<<endl;
cout<<setw(4)<<num<<setw(10)<<name<<setw(6)<<sex<<setw(10)<<position<<endl;
}
int main()
{
Student stu[2]={Student(1001,"Zhang","male","Student"),Student(1023,"Wang","male","Student")};
Teacher t1;
for(int i=0;i<2;i++)
t1.display(stu[i] );
return 0;
}