#include <iostream>
#include <string>
using namespace std;
class Student
{
protected:
	int num;
	string name;
public:
	void display();                             //声明输出函数display
	Student(int n,string n1);                     //声明构造函数
};
void Student::display()                          //定义输出函数display
{
	cout<<"num: "<<num<<endl;
	cout<<"name: "<<name<<endl;
}
Student::Student(int n,string n1)                    //定义构造函数
{
	num=n;
	name=n1;
}
class NewStudent:public Student                    //建立派生类NewStudent
{
private:
	char sex;
	int age;
	Student graduate;                            //定义子对象
public:
	void display1();                             //声明输出函数display1
	void display2();                             //声明输出函数display2
	NewStudent(int n,string n1,int n2,string n3,char s,int a); //声明派生类构造函数
};
void NewStudent::display1()                       //定义输出函数display1
{
	display();                                  //调用函数display
	cout<<"sex: "<<sex<<endl;
	cout<<"age: "<<age<<endl;
}
void NewStudent::display2()                       //定义输出函数display2
{
	cout<<"the graduate is:"<<endl;
	graduate.display();                           //利用子对象调用输出函数
}
NewStudent::NewStudent(int n,string n1,int n2,string n3,char s,int a):Student(n,n1),graduate(n2,n3)
                                              //定义派生类构造函数
{
	sex=s;
	age=a;
}
int main()
{
	NewStudent t(2010,"zhangsan",2008,"lisi",'m',20); //建立派生类对象t，并赋值
	t.display1();                               //调用输出函数display1
	t.display2();                               //调用输出函数display2
	return 0;
}
