01

#include<bits/stdc++.h>
using namespace std;//类与对象
class person
{
public://类外不可以访问,类内可以访问
char name[40];
int number;
char major[100];
char sex[40];
public://类外和类内都可以访问
void input()
{
cout<<"input your name:";
cin>>name;
cout<<"input your number:";
cin>>number;
cout<<"input your major:";
cin>>major;
cout<<"input your sex:";
cin>>sex;
}
void output()
{
cout<<"name="<<name<<endl;
cout<<"number="<<number<<endl;
cout<<"major="<<major<<endl;
cout<<"sex="<<sex<<endl;
}

};
int main()
{
person p1;
p1.input();
p1.output();

}

posted @ 2022-10-28 16:27  13763857269  阅读(19)  评论(0)    收藏  举报