您的位置:首页 > 其它

第五章t2

2015-06-01 22:13 281 查看
#include<iostream>
#include<string>
using namespace std;
class Student
{
public:
void get_value()
{
cin>>num>>name>>sex;
}
void display()
{
cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;
}
private:
int num;
string name;
char sex;
};
class Student1:private Student
{
public:
void get_value_1()
{
get_value();
cin>>age>>addr;
}
void display_1()
{
display();
cout<<"age:"<<age<<endl;
cout<<"addr:"<<addr<<endl;
}
private:
int age;
string addr;
};
int main()
{
Student1 stud;
stud.get_value_1();
stud.display_1();
return 0;
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: