用c++实现学生信息管理系统

#include
#include
#include

using namespace std;
#define MAXSIZE 20

class aclass;
class student
{
private:
long no;
char name[10];
float score;
public:
student();
friend class aclass;//友元内的定义,aclass 中的成员函数均有资格访问student的数据成员,反之不可。

};
class aclass
{
private:
char cname[10];
student data[MAXSIZE];
int last;
public:
aclass();
int insert_seqlist(int i,student x);
int delete_seqlist(int i);
void print_seqlist();

};

void menu();

int main()
{
aclass sq;
int n,m=1;
while(m)
{
menu();
cin>>n;
switch(n)
{
case 1:
{
int i;
student x;
cout<<“请输入位置”< cin>>i;
sq.insert_seqlist(i,x);

            break;
        }
    case 2:
        {
            int i;
            cout<<"请输入删除的位置:";
            cin>>i;
            sq.delete_seqlist(i);
            cout<

}

return 0;

}

void menu()
{
cout< cout<<“2.删除”< cout<<“0.退出”< cout<

}

student::student()
{
no=0;
strcpy(name,"");
score=0;

}

aclass::aclass()
{
cout<<“请输入班级名称”< cin>>cname;
last=-1;
}

int aclass::insert_seqlist(int i,student x)
{

int j;
if(last==MAXSIZE-1)
{
    cout<<"table is full!"<(last+2))
{
    cout<<"位置错误"<>x.no>>x.name>>x.score;

for(j=last;j>=i-1;j--)
{
    data[j+1]=data[j];
}
data[i-1]=x;
last++;
cout<

}

int aclass::delete_seqlist(int i)
{
int j;
if(i<1||i>(last+1))
{
cout<<“位置错误!”< return(0);
}
for(j=i;j<=last;j++)
{
data[j-1]=data[j];
}
last–;
return(1);

}
void aclass::print_seqlist()
{
int i;
cout<<“班级”< cout<<“学生”< for(i=0;i<=last;i++)
{
cout< }
cout< }

你可能感兴趣的:(用c++实现学生信息管理系统)