声明并定义一个学生信息类
#include <iostream>
#include<cstring>
using namespace std;
class StInfo
{
public:
int SID;
char Name[20];
char Class[20];
char Phone[20];
void SetInfo(int a,char b[],char c[],char d[]);
void PrintInfo();
};
void StInfo::SetInfo(int a,char b[],char c[],char d[])
{
SID=a;
strcpy(Name,b);
strcpy(Class,c);
strcpy(Phone,d);
}
void StInfo::PrintInfo()
{
cout<<"学号:"<<SID<<endl;
cout<<"姓名:"<<Name<<endl;
cout<<"班级:"<<Class<<endl;
cout<<"手机号:"<<Phone<<endl;
}