帮我看一下这个程序的错误
#include <stdio.h>#include <iostream.h>
class ka
{
public:
int p,num,sum;
};
class b
{
public:
int n,re;
};
class com
{
private:
int text;
ka a[10],*p;
b bb,*pp;
public:
void zengjia()
{
int n;
FILE *fp;
char ch;
pp=bb;
if((fp=fopen("list1","wb+"))==NULL)
{
printf("Cannot open file strike any key exit!");
}
fread(pp,sizeof(class b),1,fp);
n=pp->n;
n++;p=a[n];
p->p=n;
cout<<"请输入该卡号这次购买的数量:"<<endl;
cin>>text;
p->num=text;
p->sum=p->sum+text;
if((fp=fopen("list","wb+"))==NULL)
{
printf("Cannot open file strike any key exit!");
}
fwrite(p,sizeof(class ka),1,fp);
fclose(fp);
}
void ser1()
{
int n;
FILE *fp;
char ch;
pp=bb;
if((fp=fopen("list1","wb+"))==NULL)
{
printf("Cannot open file strike any key exit!");
}
fread(pp,sizeof(class b),1,fp);
n=pp->n;
if((fp=fopen("list","wb+"))==NULL)
{
printf("Cannot open file strike any key exit!");
}
fread(p,sizeof(class ka),1,fp);
fclose(fp);
int k,i;
cout<<"请输入要查询资料的卡号n_"<<endl;
cin>>k;
for(i=1;i<=n;i++)
if(p->p==k)
{
cout<<"该卡号上次购买的数量是:"<<"\t"<<p->num<<endl;
cout<<"该卡号一共购买的数量是:"<<"\t"<<p->sum<<endl;
}
}
void ser2()
{
int n;
FILE *fp;
char ch;
pp=bb;
if((fp=fopen("list1","wb+"))==NULL)
{
printf("Cannot open file strike any key exit!");
}
fread(pp,sizeof(class b),1,fp);
n=pp->n;
int i;p=a;
if((fp=fopen("list","wb+"))==NULL)
{
printf("Cannot open file strike any key exit!");
}
fread(p,sizeof(class ka),1,fp);
fclose(fp);
int sum,N,text1;
for(i=1;i<=n;i++)
sum=sum+p->sum;
N=n;
text1=sum/N;
cout<<"所有会员一共购买的数量是:"<<"\t"<<sum<<endl;
cout<<"会员总数是:"<<"\t"<<N<<endl;
cout<<"会员的平均消费水平是"<<"\t"<<text1<<endl;
}
};
void main()
{
com con;
int N;
cout<<"1"<<"\t"<<"增加卡号"<<endl;
cout<<"2"<<"\t"<<"查询卡号"<<endl;
cout<<"3"<<"\t"<<"查询总数"<<endl;
cout<<"请输入要进行项目:N_";
cin>>N;
switch(N)
{
case 1:
{
con.zengjia();
break;
}
case 2:
{
con.ser1();
break;
}
case 3:
{
con.ser2();
break;
}
}
}