#include <iostream>
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:public Student
{
public:
void display_1()
{
display();
cout << "age:" << age << endl;
cout << "address:" << addr << endl;
}
void get_value1()
{
cin >> age >> addr;
}
private:
int age;
string addr;
};
int main()
{
Student1 stu;
stu.get_value();
stu.get_value1();
stu.display_1();
system("pause");
return 0;
}
|