class student {
public:
void display();
void input();
private:
int num;
string name;
string sex;
};
void student::display() {
cout << "num is:" << num<<endl;
cout << "name is:" << name << endl;
cout << "sex is:" << sex << endl;
}
void student::input() {
cin >> num;
cin >> name;
cin >> sex;
}
class student1 :public student
{
public:
void display_1();
void input_1();
private:
string address;
int age;
};
void student1::display_1() {
display();
cout << "age is:" << age << endl;
cout << "address is:" << address << endl;
}
void student1::input_1() {
input();
cin >> age;
cin >> address;
}
int main() {
student1 s;
s.input_1();
s.display_1();
}
谭浩强C++第四版11.1
最新推荐文章于 2024-09-27 17:57:19 发布