#include<iostream>
#include<string>
using namespace std;
class person
{
protected:
int age;
string sex;
public:
string name;
void display();
};
void person::display()
{
cout<<"姓名"<<name<<endl;
cout<<"性别"<<sex<<endl;
cout<<"年龄"<<age<<endl;
}
class student:protected person
{
public:
string stuno;
void setsex(string p_sex);
void setname(string p_name);
void setage(int p_age);
void s_display();
};
void student::s_display()
{
cout<<"学号"<<stuno<<endl;
display();
}
void student::setsex(string p_sex)
{
sex=p_sex;
}
void student::setname(string p_name)
{
name=p_name;
}
void student::setage(int p_age)
{
age=p_age;
}
class student1:public student
{
public:
string title;
void s1_display();
};
void student1:: s1_display()
{
s_display();
cout<<"职位:"<<title<<endl;
}
int main()
{
student1 stud1;
stud1.stuno="2016061214";
stud1.title="帮主";
stud1.setname("wangming");
stud1.setsex("男");
stud1.setage(20);
stud1.s1_display();
return 0;
}
#include<string>
using namespace std;
class person
{
protected:
int age;
string sex;
public:
string name;
void display();
};
void person::display()
{
cout<<"姓名"<<name<<endl;
cout<<"性别"<<sex<<endl;
cout<<"年龄"<<age<<endl;
}
class student:protected person
{
public:
string stuno;
void setsex(string p_sex);
void setname(string p_name);
void setage(int p_age);
void s_display();
};
void student::s_display()
{
cout<<"学号"<<stuno<<endl;
display();
}
void student::setsex(string p_sex)
{
sex=p_sex;
}
void student::setname(string p_name)
{
name=p_name;
}
void student::setage(int p_age)
{
age=p_age;
}
class student1:public student
{
public:
string title;
void s1_display();
};
void student1:: s1_display()
{
s_display();
cout<<"职位:"<<title<<endl;
}
int main()
{
student1 stud1;
stud1.stuno="2016061214";
stud1.title="帮主";
stud1.setname("wangming");
stud1.setsex("男");
stud1.setage(20);
stud1.s1_display();
return 0;
}