#include <iostream> using namespace std; class Student { private: int a; int b; public: setname() { cin>>a; cin>>b; } showname() { cout<<"名字="<<a<<endl; cout<<"年龄="<<b<<endl; }; }; Student stu1,stu2; int main() { stu1.setname(); stu2.setname(); stu1.showname(); stu2.showname(); return 0; }