class teahcer;
class student {
public:
friend class teacher;
student(int id, string name, string sex);
private:
int id;
string name;
string sex;
float score;
};
student::student(int id, string name, string sex)
{
this->id = id;
this->name = name;
this->sex = sex;
}
class teacher {
private:
int id;
string name;
string sex;
public:
teacher(const student&S);
void disp();
};
void teacher::disp()
{
cout << "id:" << id << endl;
cout << "name:" << name << endl;
cout << "sex:" << sex << endl;
}
teacher::teacher(const student&S)
{
id = S.id;
name = S.name;
sex = S.sex;
}
int main()
{
student S(1, "qw", "boy");
teacher T(S);
T.disp();
system("pause");
}