#include <iostream>
#include <string>
using namespace std;
class Student
{
protected:
	int num;
	string name;
public:
	Student(int n,string n1);                       //在基类中声明构造函数
};
Student::Student(int n,string n1)                     //类外定义构造函数
{
	num=n;
	name=n1;
}
class NewStudent:public Student                    //建立派生类NewStudent
{
private:
	char sex;
	int age;
public:
	void display();                              //声明输出函数
	NewStudent(int n,string n1,char s,int age);        //声明派生类构造函数
};
void NewStudent::display()                        //定义输出函数
{
	cout<<"num: "<<num<<endl;
	cout<<"name: "<<name<<endl;
	cout<<"sex: "<<sex<<endl;
	cout<<"age: "<<age<<endl;
}
NewStudent::NewStudent(int n,string n1,char s,int a):Student(n,n1) //在类外定义派生类构造函数
{
	sex=s;
	age=a;
}
int main()                              
{
	NewStudent t1(2010,"zhangsan",'m',19);         //建立对象t1，并赋值
	NewStudent t2(2010,"lisi",'w',20);              //建立对象t2，并赋值
	t1.display();                                //调用函数display，输出对象t1
	t2.display();                                //调用函数display，输出对象t2
	return 0;
}

