#include<stdio.h>
#include<iostream>
#include<wchar.h>
#include<cstdlib>
#include<iomanip>
using namespace std;
class student //创建1个类
{
int no,age;
char name[25],a[20];
public:
void stu();
void stu (int &no, char name[25],int &age,char a[20]) //内置函数 引用
{
cout <<"input no:";
cin>> no;
cout <<"input name:";
cin>> name;
cout <<"input age:";
cin>> age;
cout <<"input a:";
cin>> a;
}
int getx() //访问成员函数
{
return no;
}
int gety()
{
return age;
}
};
int main()
{
//int no,age;
char name[25],a[20];
student p1;
int i,j;
i=p1.getx();
j=p1.gety();
p1.stu(i,name,j,a);
cout << i<< name<< j<< a<<endl;
return 0;
}
时间: 2024-10-10 00:25:13