#include<iostream>
using namespace std;
#include<string>
class people {
public:
void setValue(int m, string str) {
age = m;
name = str;
}
void display() {
cout << "姓名:" << name << "年龄:" << age;
}
protected:
int age;
string name;
};
class student :public people {
public:
void setID(int m) {
ID = m;
}
void displayID() {
cout << "学号:" << ID << endl;
}
private:
int ID;
};
int main()
{
student s;
s.setValue(18, "小明");
s.setID(10086);
s.display();
s.displayID();
system("pause");
return 0;
}
标签:cout,people,int,void,public,5.5 From: https://www.cnblogs.com/lml66/p/17375711.html